Skip to content

Commit

Permalink
Adapt script for new dissolution date structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed May 4, 2017
1 parent e051c3b commit 730b806
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/mpinfoin.pl
Expand Up @@ -337,6 +337,15 @@ sub loadregmeminfo
$personinfohash->{$id}->{"register_member_interests_date"} = $regmem->att('date');
}

sub commons_dissolved {
return unless mySociety::Config::get('DISSOLUTION_DATE');
my @houses = split /,/, mySociety::Config::get('DISSOLUTION_DATE');
foreach (@houses) {
my ($house, $date) = split /:/;
return $date if $house == 1;
}
}

# Generate rankings of number of times spoken
sub makerankings {
my $dbh = shift;
Expand All @@ -347,10 +356,10 @@ sub makerankings {
#"( 10001 )");
'(select person_id from member where house=1 AND curdate() <= left_house) order by person_id, entered_house');
$sth->execute();
if ($sth->rows == 0 && mySociety::Config::get('DISSOLUTION_DATE')) {
if ($sth->rows == 0 && commons_dissolved()) {
$sth = $dbh->prepare($query .
'(select person_id from member where left_house = ?)');
$sth->execute(mySociety::Config::get('DISSOLUTION_DATE'));
$sth->execute(commons_dissolved());
if ($sth->rows == 0) {
print "Failed to find any MPs for rankings, change dissolution date if you are near one";
return;
Expand Down

0 comments on commit 730b806

Please sign in to comment.