Skip to content

Commit

Permalink
[Bexley] Include user email in dashboard CSV export
Browse files Browse the repository at this point in the history
  • Loading branch information
davea committed Jan 10, 2024
1 parent a92d737 commit 79bead8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions perllib/FixMyStreet/Cobrand/Bexley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,28 @@ sub report_form_extras {

sub report_sent_confirmation_email { 'id' }

sub dashboard_export_problems_add_columns {
my ($self, $csv) = @_;

$csv->add_csv_columns(
user_email => 'User Email',
);

$csv->objects_attrs({
'+columns' => ['user.email'],
join => 'user',
});

return if $csv->dbi; # Already covered

$csv->csv_extra_data(sub {
my $report = shift;

return {
user_email => $report->user->email || '',
};
});
}


1;
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Script/CSVExport.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ my $EXTRAS = {
assigned_to => { northumberland => 1, tfl => 1 },
staff_user => { bathnes => 1, bromley => 1, buckinghamshire => 1, northumberland => 1, peterborough => 1 },
staff_roles => { bromley => 1, northumberland => 1 },
user_details => { bathnes => 1, brent => 1, camden => 1, highwaysengland => 1, kingston => 1, sutton => 1 },
user_details => { bathnes => 1, bexley => 1, brent => 1, camden => 1, highwaysengland => 1, kingston => 1, sutton => 1 },
comment_content => { highwaysengland => 1 },
db_state => { peterborough => 1 },
};
Expand Down
6 changes: 5 additions & 1 deletion t/cobrand/bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ FixMyStreet::override_config {
is $c->param('service_code'), 'StreetLightingLAMP', 'Report resent';
};

subtest 'extra CSV column present' => sub {
subtest 'extra CSV columns present' => sub {
$mech->get_ok('/dashboard?export=1');
$mech->content_contains(',Category,Subcategory,');
$mech->content_contains('"Danger things","Something dangerous"');

my $report = FixMyStreet::DB->resultset("Problem")->first;
$mech->content_contains(',"User Email"');
$mech->content_contains(',' . $report->user->email);
};


Expand Down

0 comments on commit 79bead8

Please sign in to comment.