Skip to content

Commit

Permalink
[Northumberland] Add shortlisted to stats summary
Browse files Browse the repository at this point in the history
  • Loading branch information
MorayMySoc authored and dracos committed Oct 20, 2023
1 parent f0ee8cf commit fe57e04
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions perllib/FixMyStreet/Cobrand/Northumberland.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ sub dashboard_export_problems_add_columns {
$csv->add_csv_columns(
staff_user => 'Staff User',
staff_role => 'Staff Role',
assigned_to => 'Assigned To',
);

my $user_lookup = $self->csv_staff_users;
my $userroles = $self->csv_staff_roles($user_lookup);
my $problems_to_user = $self->csv_active_planned_reports;

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

my $by = $report->get_extra_metadata('contributed_by');
my $staff_user = '';
my $staff_role = '';
my $assigned_to = '';
if ($by) {
$staff_user = $self->csv_staff_user_lookup($by, $user_lookup);
$staff_role = join(',', @{$userroles->{$by} || []});
Expand All @@ -107,6 +110,7 @@ sub dashboard_export_problems_add_columns {
user_name_display => $report->name,
staff_user => $staff_user,
staff_role => $staff_role,
assigned_to => $problems_to_user->{$report->id} || '',
};
});
}
Expand Down
12 changes: 12 additions & 0 deletions perllib/FixMyStreet/Cobrand/UKCouncils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,18 @@ sub csv_staff_roles {
return \%userroles;
}

sub csv_active_planned_reports {
my ($self) = @_;

my %reports_to_user;
my @cobrand_users = FixMyStreet::DB->resultset('User')->search({ from_body => $self->body->id});

for my $user (@cobrand_users) {
map { $reports_to_user{$_->report_id} = $user->name } @{$user->active_user_planned_reports};
}
return \%reports_to_user;
}

sub nearby_distances {
my $self = shift;
return $self->feature('nearby_distances') || $self->next::method();
Expand Down
11 changes: 9 additions & 2 deletions t/cobrand/northumberland.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ my $staffuser = $mech->create_user_ok('[email protected]', name => 'Counci
my $role = FixMyStreet::DB->resultset("Role")->create({ name => 'Role 1', body => $body, permissions => [], });
$staffuser->add_to_roles($role);

$mech->create_problems_for_body(1, $body->id, 'Test', {
my ($problem1, $problem2) = $mech->create_problems_for_body(2, $body->id, 'Test', {
anonymous => 't',
extra => { contributed_by => $staffuser->id },
});
Expand All @@ -24,7 +24,14 @@ FixMyStreet::override_config {
$mech->log_in_ok( $staffuser->email );
$mech->get_ok('/dashboard?export=1');
$mech->content_contains('Test User', 'name of anonymous user');
$mech->content_contains('[email protected],"Role 1"', 'staff user and role');
$mech->content_like(qr{counciluser\@example.com,"Role 1",$}, 'staff user, role, and unassigned');
$staffuser->add_to_planned_reports($problem1);
$staffuser->add_to_planned_reports($problem2);
$mech->get_ok('/dashboard?export=1');
my $id1 = $problem1->id;
my $id2 = $problem2->id;
$mech->content_like(qr{/report/$id1,.*?,"Role 1","Council User"}, 'staff user, role, and assigned to');
$mech->content_like(qr{/report/$id2,.*?,"Role 1","Council User"}, 'staff user, role, and assigned to');
};

subtest 'Staff OOH shown on National Highways roads' => sub {
Expand Down

0 comments on commit fe57e04

Please sign in to comment.