Skip to content

Commit

Permalink
Add person identifiers to personinfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Mar 11, 2024
1 parent 1243ef0 commit 4ee8fa7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/load-people
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ verbose("End");

# ---

my ($dbh, $memberadd, $memberexist, $membercheck, $nameadd, $nameupdate, $namefetch, $namedelete, $gradd, $grdelete, $start_transaction, $query_commit, );
my ($dbh, $memberadd, $memberexist, $membercheck, $personinfoupdate, $nameadd, $nameupdate, $namefetch, $namedelete, $gradd, $grdelete, $start_transaction, $query_commit, );

sub db_connect {
#DBI->trace(1);
Expand All @@ -70,6 +70,8 @@ sub db_connect {
and constituency = ? and party = ? and entered_house = ? and left_house = ?
and entered_reason = ? and left_reason = ?");

$personinfoupdate = $dbh->prepare("insert into personinfo (person_id, data_key, data_value) values (?, ?, ?) on duplicate key update data_value=?");

$nameadd = $dbh->prepare("insert into person_names (person_id, title, given_name,
family_name, lordofname, start_date, end_date) values (?, ?, ?, ?, ?, ?, ?)");
$nameupdate = $dbh->prepare("replace into person_names (id, person_id, title, given_name,
Expand Down Expand Up @@ -163,6 +165,7 @@ sub load_people {
if ($_->{redirect}) {
$gradd->execute($_->{id}, $_->{redirect});
} else {
load_identifiers($_);
load_names($_);
}
}
Expand Down Expand Up @@ -217,6 +220,17 @@ sub load_member {
);
}

sub load_identifiers {
my $person = shift;

my $id = $person->{id};
$id =~ s#uk.org.publicwhip/person/##;

foreach (@{$person->{identifiers}}) {
$personinfoupdate->execute($id, $_->{scheme}, $_->{identifier}, $_->{identifier});
}
}

sub load_names {
my $person = shift;

Expand Down

0 comments on commit 4ee8fa7

Please sign in to comment.