diff options
author | M Somerville <matthew-github@dracos.co.uk> | 2020-10-06 13:42:38 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-10-14 09:23:30 +0100 |
commit | c419e88385f287f6f593f28a0ec0e8a9ae8b0bd4 (patch) | |
tree | 01c0b0b8fdc23cfd8ae00a17b4c88b44f59ed91a | |
parent | 98cc29c15b98a26f75adabb1c07acdd9513b4446 (diff) |
[TfL] Include move to action scheduled in export.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/TfL.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Reporting.pm | 14 | ||||
-rw-r--r-- | t/cobrand/tfl.t | 8 |
3 files changed, 23 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm index 9cf8910f9..b04841c39 100644 --- a/perllib/FixMyStreet/Cobrand/TfL.pm +++ b/perllib/FixMyStreet/Cobrand/TfL.pm @@ -254,6 +254,7 @@ sub dashboard_export_problems_add_columns { reassigned_at => "Reassigned at", reassigned_by => "Reassigned by", ); + $csv->splice_csv_column('fixed', action_scheduled => 'Action scheduled'); if ($csv->category) { my @contacts = $csv->body->contacts->search(undef, { order_by => [ 'category' ] } )->all; diff --git a/perllib/FixMyStreet/Reporting.pm b/perllib/FixMyStreet/Reporting.pm index 4573d78fc..efd12718c 100644 --- a/perllib/FixMyStreet/Reporting.pm +++ b/perllib/FixMyStreet/Reporting.pm @@ -58,6 +58,19 @@ sub modify_csv_header { ]); } +sub splice_csv_column { + my ($self, $before, $column, $header) = @_; + + for (my $i = 0; $i < @{$self->csv_columns}; $i++) { + my $col = $self->csv_columns->[$i]; + if ($col eq $before) { + splice @{$self->csv_columns}, $i, 0, $column; + splice @{$self->csv_headers}, $i, 0, $header; + last; + } + } +} + sub add_csv_columns { my $self = shift; for (my $i = 0; $i < @_; $i += 2) { @@ -255,6 +268,7 @@ sub generate_csv { next unless $comment->state eq 'confirmed'; next if $problem_state eq 'confirmed'; $hashref->{acknowledged} //= $comment->confirmed; + $hashref->{action_scheduled} //= $problem_state eq 'action scheduled' ? $comment->confirmed : undef; $hashref->{fixed} //= $fixed_states->{ $problem_state } || $comment->mark_fixed ? $comment->confirmed : undef; if ($closed_states->{ $problem_state }) { diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index 3aabb07db..142c7c14e 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -425,6 +425,7 @@ subtest 'Dashboard CSV extra columns' => sub { $mech->get_ok('/dashboard?export=1&category=Bus+stops'); $mech->content_contains('Category,Subcategory'); $mech->content_contains('Query,Borough'); + $mech->content_contains(',Acknowledged,"Action scheduled",Fixed'); $mech->content_contains(',"Safety critical","Delivered to","Closure email at","Reassigned at","Reassigned by","Is the pole leaning?"'); $mech->content_contains('"Bus things","Bus stops"'); $mech->content_contains('"BR1 3UH",Bromley,'); @@ -442,10 +443,17 @@ subtest 'Dashboard CSV extra columns' => sub { admin_user => $staffuser->name, user => $staffuser, }); + FixMyStreet::DB->resultset('Comment')->create({ + problem => $report, user => $report->user, anonymous => 't', text => 'Update text', + problem_state => 'action scheduled', state => 'confirmed', mark_fixed => 0, + confirmed => $dt, + }); $mech->get_ok('/dashboard?export=1'); $mech->content_contains('Query,Borough'); + $mech->content_contains(',Acknowledged,"Action scheduled",Fixed'); $mech->content_contains(',"Safety critical","Delivered to","Closure email at","Reassigned at","Reassigned by"'); $mech->content_contains('(anonymous ' . $report->id . ')'); + $mech->content_contains($dt . ',,,confirmed,51.4021'); $mech->content_contains(',,,yes,busstops@example.com,,' . $dt . ',"Council User"'); }; |