Skip to content

Commit

Permalink
[Southwark] Include user email in CSV report export.
Browse files Browse the repository at this point in the history
  • Loading branch information
neprune committed Jan 27, 2025
1 parent ed9a799 commit fea0f9e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
29 changes: 29 additions & 0 deletions perllib/FixMyStreet/Cobrand/Southwark.pm
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,33 @@ sub _filter_categories_by_group {
return values %contacts_hash;
}

=head2 dashboard_export_problems_add_columns
Has user email added to their csv reports export.
=cut

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

Check warning on line 283 in perllib/FixMyStreet/Cobrand/Southwark.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Southwark.pm#L283

Added line #L283 was not covered by tests

$csv->add_csv_columns(

Check warning on line 285 in perllib/FixMyStreet/Cobrand/Southwark.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Southwark.pm#L285

Added line #L285 was not covered by tests
user_email => 'User Email',
);

$csv->objects_attrs({

Check warning on line 289 in perllib/FixMyStreet/Cobrand/Southwark.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Southwark.pm#L289

Added line #L289 was not covered by tests
'+columns' => ['user.email'],
join => 'user',
});

return if $csv->dbi; # user_email already included.

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

Check warning on line 297 in perllib/FixMyStreet/Cobrand/Southwark.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Southwark.pm#L297

Added line #L297 was not covered by tests
return {
user_email => $report->user ? $report->user->email : '',
};
});

Check warning on line 301 in perllib/FixMyStreet/Cobrand/Southwark.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Southwark.pm#L301

Added line #L301 was not covered by tests
}


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 => { brent => 1, bromley => 1, northumberland => 1, oxfordshire => 1 },
user_details => { bathnes => 1, bexley => 1, brent => 1, camden => 1, cyclinguk => 1, highwaysengland => 1, kingston => 1, sutton => 1 },
user_details => { bathnes => 1, bexley => 1, brent => 1, camden => 1, cyclinguk => 1, highwaysengland => 1, kingston => 1, southwark => 1, sutton => 1 },
comment_content => { highwaysengland => 1 },
db_state => { peterborough => 1 },
alerts_count => { surrey => 1 },
Expand Down
13 changes: 13 additions & 0 deletions t/cobrand/southwark.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ my $southwark = $mech->create_body_ok(
{ cobrand => 'southwark' },
);

my $staffuser = $mech->create_user_ok( '[email protected]', name => 'Staffer', from_body => $southwark );

$mech->create_contact_ok(
body_id => $southwark->id,
category => 'Abandoned Bike (Street)',
Expand Down Expand Up @@ -97,6 +99,17 @@ FixMyStreet::override_config {
}, "Southwark 'estate' area doesn't have TfL categories or street category";

};

subtest 'Dashboard CSV extra columns' => sub {
$mech->log_in_ok($staffuser->email);
$mech->create_problems_for_body(1, $southwark->id, 'Title', {
user => $staffuser,
cobrand => 'southwark',
});
$mech->get_ok('/dashboard?export=1');
$mech->content_contains('"User Email"');
$mech->content_contains($staffuser->email);
};
};

done_testing;

0 comments on commit fea0f9e

Please sign in to comment.