diff options
author | Dave Arter <davea@mysociety.org> | 2020-04-30 10:35:15 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-04-30 10:35:15 +0100 |
commit | 33fda5fe84a3820ea4a03441bb2d2b1f9b44d693 (patch) | |
tree | 6e1c862702a2c2f3bb2682202f7e07d11de72cd6 | |
parent | b7d50b149173f9640a4d8566c9bd5b2980c30b6d (diff) |
[Oxfordshire] Include Exor problem reference in CSV export
The Exor reference was missed from the previous commit.
For https://github.com/mysociety/fixmystreet-commercial/issues/1876
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 16 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index b110731e6..8ce12a81b 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -206,13 +206,21 @@ sub dashboard_export_problems_add_columns { my $self = shift; my $c = $self->{c}; - push @{$c->stash->{csv}->{headers}}, "HIAMS Ref"; - push @{$c->stash->{csv}->{columns}}, "customer_reference"; + push @{$c->stash->{csv}->{headers}}, "HIAMS/Exor Ref"; + push @{$c->stash->{csv}->{columns}}, "external_ref"; $c->stash->{csv}->{extra_data} = sub { - my $ref = shift->get_extra_metadata('customer_reference') || ''; + my $report = shift; + # Try and get a HIAMS reference first of all + my $ref = $report->get_extra_metadata('customer_reference'); + unless ($ref) { + # No HIAMS ref which means it's either an older Exor report + # or a HIAMS report which hasn't had its reference set yet. + # We detect the latter case by the id and external_id being the same. + $ref = $report->external_id if $report->id ne ( $report->external_id || '' ); + } return { - customer_reference => $ref, + external_ref => ( $ref || '' ), }; }; } diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 907c66c19..1d59909b9 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -112,6 +112,9 @@ subtest 'extra CSV columns are present' => sub { MAPIT_URL => 'http://mapit.uk/', }, sub { + $problems[1]->update({ external_id => $problems[1]->id }); + $problems[2]->update({ external_id => "123098123" }); + $mech->log_in_ok( $counciluser->email ); $mech->get_ok('/dashboard?export=1'); @@ -126,11 +129,13 @@ subtest 'extra CSV columns are present' => sub { 'Created', 'Confirmed', 'Acknowledged', 'Fixed', 'Closed', 'Status', 'Latitude', 'Longitude', 'Query', 'Ward', 'Easting', 'Northing', 'Report URL', 'Site Used', - 'Reported As', 'HIAMS Ref', + 'Reported As', 'HIAMS/Exor Ref', ], 'Column headers look correct'; is $rows[1]->[20], 'ENQ12456', 'HIAMS reference included in row'; + is $rows[2]->[20], '', 'Report without HIAMS ref has empty ref field'; + is $rows[3]->[20], '123098123', 'Older Exor report has correct ref'; }; }; |