Skip to content

Commit

Permalink
Move post-retirement check to config.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed May 26, 2024
1 parent b0f0c2e commit 81c138e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
12 changes: 12 additions & 0 deletions conf/general-example
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ define ("RECESSFILE","https://www.theyworkforyou.com/pwdata/parl-recesses.txt");

define("TWFY_VOTES_URL", "");

define('ENTRIES_AFTER_LEFT', '{
"10170,2014-09-08": "2014-09-07",
"11068,2008-09": "2008-08-13",
"25394,2016-07-01": "2016-06-16",
"10599,2021-02": "2021-02-19",
"25942,2021-09-17": "2021-05-07",
"11667,2022-12": "2022-11-30",
"13485,2023-07": "2023-07-27",
"13485,2023-08": "2023-07-27",
"10578,2024-05-01": "2024-04-29",
"13633,2024-05": "2024-05-20"
}');

// *******************************************************************************
// More Email addresses.
Expand Down
17 changes: 8 additions & 9 deletions search/index.pl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
101 => { 2 => 1 },
);

my $after_left = mySociety::Config::get('ENTRIES_AFTER_LEFT') || '{}';
$after_left = decode_json($after_left);

# Be aware of redirected persons - code similar to xml2db.pl
my %personredirect;
my $pwmembers = mySociety::Config::get('PWMEMBERS');
Expand Down Expand Up @@ -369,18 +372,14 @@ sub get_person {
$person_id = $personredirect{$person_id} || $person_id;

# Special exemptions for people 'speaking' after they have left
# Note identical code to this in hansardlist.php
$hdate = '20140907' if $person_id == 10170 && $hdate eq '20140908';
$hdate = '20080813' if $person_id == 11068 && substr($hdate, 0, 6) eq '200809';
$hdate = '20160616' if $person_id == 25394 && $hdate eq '20160701';
$hdate = '20210219' if $person_id == 10599 && substr($hdate, 0, 6) eq '202102';
$hdate = '20221130' if $person_id == 11667 && substr($hdate, 0, 6) eq '202212';
$hdate = '20230727' if $person_id == 13485 && $hdate gt '20230727';
$hdate = '20240429' if $person_id == 10578 && $hdate gt '20240429';
(my $hhdate = $hdate) =~ s/(\d\d\d\d)(\d\d)(\d\d)/\1-\2-\3/;
my $hhdate_month = substr($hhdate, 0, 7);
$hhdate = $after_left->{"$person_id,$hhdate"} || $hhdate;
$hhdate = $after_left->{"$person_id,$hhdate_month"} || $hhdate;
($hdate = $hhdate) ~ s/-//g;

# London questions answered after election
$hdate = '20210507' if $major == 9 && ($hdate eq '20210511' || $hdate eq '20210510');
$hdate = '20210507' if $person_id == 25942 && $major == 9 && $hdate eq '20210917';

my @matches = @{$dbh->selectall_arrayref($q_person, { Slice => {} }, $person_id, $hdate, $hdate, $hdate, $hdate)};
if (@matches > 1) {
Expand Down
23 changes: 4 additions & 19 deletions www/includes/easyparliament/hansardlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class HANSARDLIST {

public function __construct() {
$this->db = new ParlDB;
$this->after_left = json_decode(ENTRIES_AFTER_LEFT, 1) ?? [];
}


Expand Down Expand Up @@ -2088,30 +2089,14 @@ public function _get_speaker($person_id, $hdate, $htime, $major) {
}

# Special exemptions for people 'speaking' after they have left
# Note identical code to this in search/index.pl
if ($person_id == 10170 && $hdate == '2014-09-08') {
$hdate = '2014-09-07';
} elseif ($person_id == 11068 && substr($hdate, 0, 7) == '2008-09') {
$hdate = '2008-08-13';
} elseif ($person_id == 25394 && $hdate == '2016-07-01') {
$hdate = '2016-06-16';
} elseif ($person_id == 10599 && substr($hdate, 0, 7) == '2021-02') {
$hdate = '2021-02-19';
} elseif ($person_id == 11667 && substr($hdate, 0, 7) == '2022-12') {
$hdate = '2022-11-30';
} elseif ($person_id == 13485 && $hdate > '2023-07-27') {
$hdate = '2023-07-27';
} elseif ($person_id == 10578 && $hdate > '2024-04-29') {
$hdate = '2024-04-29';
}
$hdate_month = substr($hdate, 0, 7);
$hdate = $this->after_left["$person_id,$hdate"] ?? $hdate;
$hdate = $this->after_left["$person_id,$hdate_month"] ?? $hdate;

# London questions answered after election
if ($major == 9 && ($hdate == '2021-05-11' || $hdate == '2021-05-10')) {
$hdate = '2021-05-07';
}
if ($person_id == 25942 && $major == 9 && $hdate == '2021-09-17') {
$hdate = '2021-05-07';
}

# check for a person redirect
$q = $this->db->query("SELECT gid_to FROM gidredirect
Expand Down

0 comments on commit 81c138e

Please sign in to comment.