diff options
author | Struan Donald <struan@exo.org.uk> | 2020-09-20 17:36:30 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-09-21 05:44:11 +0100 |
commit | 92dbe2100f813dbad20f15fa42d597495b7f7e40 (patch) | |
tree | 0a511ef0ce0ba32e43d7a29b9138d746bb2623ec /bin | |
parent | fd31e8f629b9bc04486c8e3f0f6e330868b38597 (diff) |
[Northamptonshire] improve external id mapping script
Now uses FixMyStreet id as the lookup based on external_id was much too
slow in practice
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/northamptonshire/update_ids_for_v2 | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/northamptonshire/update_ids_for_v2 b/bin/northamptonshire/update_ids_for_v2 index eac52b938..2876bb0d8 100755 --- a/bin/northamptonshire/update_ids_for_v2 +++ b/bin/northamptonshire/update_ids_for_v2 @@ -22,6 +22,7 @@ use Text::CSV; my $NEW_ID = 'alloy_item_id'; my $OLD_ID = 'res_id'; +my $FMS_ID = 'fms_id'; my ($commit, $file); GetOptions( @@ -42,14 +43,19 @@ my $northants = FixMyStreet::DB->resultset("Body")->find({ name => 'Northamptons if ($northants) { while (my $report = $csv->getline_hr( $fh ) ) { next unless $report->{$OLD_ID}; - my $p = FixMyStreet::DB->resultset('Problem')->to_body( $northants->id )->search({ external_id => $report->{$OLD_ID} })->first; + my $p = FixMyStreet::DB->resultset('Problem')->to_body( $northants->id )->search({ id => $report->{$FMS_ID} })->first; next unless $p; + if ( $p->external_id ne $report->{$OLD_ID} ) { + warn "mismatch for " . $report->{$FMS_ID} . "\n"; + next; + } if ($commit) { $p->set_extra_metadata('old_external_id', $p->external_id); $p->external_id($report->{$NEW_ID}); $p->update; } + say "Processed $count" if $count % 100 == 0; $count++; } |