Skip to content

Commit

Permalink
[Brent] Include extra details in CSV export.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 17, 2025
1 parent d0c2504 commit 4a3c3d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ sub dashboard_export_problems_add_columns {
uprn => 'UPRN',
external_id => 'External ID',
image_included => 'Does the report have an image?',
extra_details => 'Extra details',

InspectionDate => "Inspection date",
GradeLitter => "Grade for Litter",
Expand Down Expand Up @@ -527,6 +528,7 @@ sub dashboard_export_problems_add_columns {

my $data = {
location_name => $csv->_extra_field($report, 'location_name'),
extra_details => $csv->_extra_metadata($report, 'detailed_information') || '',
$csv->dbi ? (
street_name => FixMyStreet::Geocode::Address->new($report->{geocode})->parts->{street},
image_included => $report->{photo} ? 'Y' : 'N',
Expand Down
22 changes: 11 additions & 11 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ subtest 'Dashboard CSV extra columns' => sub {
areas => "2488", category => 'Request new container', cobrand => 'brent', user => $user1, state => 'confirmed'});
$mech->log_in_ok( $staff_user->email );
$mech->get_ok('/dashboard?export=1');
ok $mech->content_contains('"Created By",Email,USRN,UPRN,"External ID","Does the report have an image?","Inspection date","Grade for Litter","Grade for Detritus","Grade for Graffiti","Grade for Fly-posting","Grade for Weeds","Overall Grade","Did you see the fly-tipping take place","If \'Yes\', are you willing to provide a statement?","How much waste is there","Type of waste","Container Request Action","Container Request Container Type","Container Request Reason","Email Renewal Reminders Opt-In","Service ID","Staff Role","Small Item 1","Small Item 2"', "New columns added");
ok $mech->content_contains('"Created By",Email,USRN,UPRN,"External ID","Does the report have an image?","Extra details","Inspection date","Grade for Litter","Grade for Detritus","Grade for Graffiti","Grade for Fly-posting","Grade for Weeds","Overall Grade","Did you see the fly-tipping take place","If \'Yes\', are you willing to provide a statement?","How much waste is there","Type of waste","Container Request Action","Container Request Container Type","Container Request Reason","Email Renewal Reminders Opt-In","Service ID","Staff Role","Small Item 1","Small Item 2"', "New columns added");
ok $mech->content_like(qr/Flexible problem.*?"Test User",pkg-tcobrandbrentt/, "User and email added");
ok $mech->content_like(qr/Flexible problem.*?,,,,Y,,,,,,,,/, "All fields empty but photo exists");
$flexible_problem->set_extra_fields(
Expand All @@ -1473,7 +1473,7 @@ subtest 'Dashboard CSV extra columns' => sub {
$flexible_problem->external_id('121');
$flexible_problem->update;
$mech->get_ok('/dashboard?export=1');
ok $mech->content_like(qr/Flexible problem.*?,1234,4321,121,Y,,,,,,,,,,,,Deliver,"Blue rubbish sack",Missing,,1/, "Bin request values added");
ok $mech->content_like(qr/Flexible problem.*?,1234,4321,121,Y,,,,,,,,,,,,,Deliver,"Blue rubbish sack",Missing,,1/, "Bin request values added");
$flexible_problem->category('Fly-tipping');
$flexible_problem->set_extra_fields(
{name => 'Did_you_see_the_Flytip_take_place?_', value => 1},
Expand All @@ -1483,21 +1483,21 @@ subtest 'Dashboard CSV extra columns' => sub {
);
$flexible_problem->update;
$mech->get_ok('/dashboard?export=1');
ok $mech->content_like(qr/Flexible problem.*?,121,Y,,,,,,,,Yes,No,"Small van load",Appliance,/, "Flytip request values added");
ok $mech->content_like(qr/Flexible problem.*?,121,Y,,,,,,,,,Yes,No,"Small van load",Appliance,/, "Flytip request values added");
$flexible_problem->set_extra_fields(
{name => 'location_name', value => 'Test Park'},
);
$flexible_problem->update;
$mech->get_ok('/dashboard?export=1');
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,/, "Location name added") or diag $mech->content;
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,,/, "Location name added") or diag $mech->content;
$flexible_problem->set_extra_metadata('item_1' => 'Sofa', 'item_2' => 'Wardrobe');
$flexible_problem->update;
$mech->get_ok('/dashboard?export=1');
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,,Sofa,Wardrobe,,,,,,,/, "Bulky items added") or diag $mech->content;
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,,,Sofa,Wardrobe,,,,,,,/, "Bulky items added") or diag $mech->content;
$flexible_problem->set_extra_metadata('contributed_by' => $staff_user->id);
$flexible_problem->update;
$mech->get_ok('/dashboard?export=1');
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,Role,Sofa,Wardrobe,,,,,,,/, "Role added") or diag $mech->content;
ok $mech->content_like(qr/Flexible problem.*?,,,"Test Park","Test User",.*?,,,121,Y,,,,,,,,,,,,,,,,,,Role,Sofa,Wardrobe,,,,,,,/, "Role added") or diag $mech->content;
}
};

Expand Down Expand Up @@ -1534,16 +1534,16 @@ subtest 'Dashboard CSV pre-generation' => sub {
$problems[2]->update;
FixMyStreet::Script::CSVExport::process(dbh => FixMyStreet::DB->schema->storage->dbh);
$mech->get_ok('/dashboard?export=1');
$mech->content_contains('"Created By",Email,USRN,UPRN,"External ID","Does the report have an image?","Inspection date","Grade for Litter","Grade for Detritus","Grade for Graffiti","Grade for Fly-posting","Grade for Weeds","Overall Grade","Did you see the fly-tipping take place","If \'Yes\', are you willing to provide a statement?","How much waste is there","Type of waste","Container Request Action","Container Request Container Type","Container Request Reason","Email Renewal Reminders Opt-In","Service ID","Staff Role","Small Item 1","Small Item 2"', "New columns added");
$mech->content_contains('"Created By",Email,USRN,UPRN,"External ID","Does the report have an image?","Extra details","Inspection date","Grade for Litter","Grade for Detritus","Grade for Graffiti","Grade for Fly-posting","Grade for Weeds","Overall Grade","Did you see the fly-tipping take place","If \'Yes\', are you willing to provide a statement?","How much waste is there","Type of waste","Container Request Action","Container Request Container Type","Container Request Reason","Email Renewal Reminders Opt-In","Service ID","Staff Role","Small Item 1","Small Item 2"', "New columns added");
$mech->content_like(qr/Pregen problem Test 3.*?"Test User",pkg-tcobrandbrentt/, "User and email added");
$mech->content_like(qr/Pregen problem Test 3.*?,1234,4321,121,Y,,,,,,,,,,,,Collect\+Deliver,"Food waste caddy",Damaged,,1/, "Bin request values added");
$mech->content_like(qr/Pregen problem Test 2.*?,,Y,,,,,,,,Yes,No,"Small van load",Appliance,/, "Flytip request values added");
$mech->content_like(qr/Pregen problem Test 1.*?,,,"Test Park","Test User",.*?,,,,Y,,,,,,,,,,,,,,,,,,Sofa,Wardrobe,,,,,,,/, "Bulky items added");
$mech->content_like(qr/Pregen problem Test 3.*?,1234,4321,121,Y,,,,,,,,,,,,,Collect\+Deliver,"Food waste caddy",Damaged,,1/, "Bin request values added");
$mech->content_like(qr/Pregen problem Test 2.*?,,Y,,,,,,,,,Yes,No,"Small van load",Appliance,/, "Flytip request values added");
$mech->content_like(qr/Pregen problem Test 1.*?,,,"Test Park","Test User",.*?,,,,Y,,,,,,,,,,,,,,,,,,,Sofa,Wardrobe,,,,,,,/, "Bulky items added");
$problems[2]->set_extra_metadata('contributed_by' => $staff_user->id);
$problems[2]->update;
FixMyStreet::Script::CSVExport::process(dbh => FixMyStreet::DB->schema->storage->dbh);
$mech->get_ok('/dashboard?export=1');
$mech->content_like(qr/Pregen problem Test 1.*?,,,"Test Park","Test User",.*?,,,,Y,,,,,,,,,,,,,,,,,Role,Sofa,Wardrobe,,,,,,,/, "Role added");
$mech->content_like(qr/Pregen problem Test 1.*?,,,"Test Park","Test User",.*?,,,,Y,,,,,,,,,,,,,,,,,,Role,Sofa,Wardrobe,,,,,,,/, "Role added");
$mech->get_ok('/dashboard?export=1&state=investigating');
$mech->content_contains('Pregen problem Test 2');
$mech->get_ok('/dashboard?export=1&state=fixed');
Expand Down

0 comments on commit 4a3c3d9

Please sign in to comment.