aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-05-07 12:44:23 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-05-07 14:40:17 +0100
commit5ce552af2b66613272dc9cfe2d46532e057f44f7 (patch)
tree660f00556af91fecbd64386b1c23c6ca54ca20f3
parentcfabb3cfd4474c1c812ed325a068d56bafc43a08 (diff)
Fix dashboard report CSV export.
The change to join in e16054150 did not include a collapse that the previous prefetch was doing, so multiple rows per result were being returned.
-rw-r--r--CHANGELOG.md2
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm5
-rw-r--r--t/app/controller/dashboard.t3
3 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b62915428..61a56ebdd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
## Releases
* Unreleased
+ - Bugfixes:
+ - Fix issue with dashboard report CSV export. #3026
* v3.0.1 (6th May 2020)
- New features:
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index e5a526efc..833d6d6b2 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -349,14 +349,15 @@ sub export_as_csv : Private {
my $groups = $c->cobrand->enable_category_groups ? 1 : 0;
my $join = ['comments'];
- my $columns = ['comments.problem_state', 'comments.state', 'comments.confirmed', 'comments.mark_fixed'];
+ my $columns = ['comments.id', 'comments.problem_state', 'comments.state', 'comments.confirmed', 'comments.mark_fixed'];
if ($groups) {
push @$join, 'contact';
- push @$columns, 'contact.extra';
+ push @$columns, 'contact.id', 'contact.extra';
}
my $csv = $c->stash->{csv} = {
objects => $c->stash->{objects_rs}->search_rs({}, {
join => $join,
+ collapse => 1,
'+columns' => $columns,
order_by => ['me.confirmed', 'me.id'],
cursor_page_size => 1000,
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 72fc00128..c62ada89a 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -70,6 +70,7 @@ foreach my $problem (@fixed_problems) {
foreach my $problem (@closed_problems) {
$problem->update({ state => 'closed' });
+ $mech->create_comment_for_problem($problem, $counciluser, 'Name', 'in progress text', 0, 'confirmed', 'in progress');
$mech->create_comment_for_problem($problem, $counciluser, 'Title', 'text', 0, 'confirmed', 'closed');
}
@@ -214,7 +215,7 @@ FixMyStreet::override_config {
subtest 'export updates as csv' => sub {
$mech->get_ok('/dashboard?updates=1&export=1');
my @rows = $mech->content_as_csv;
- is scalar @rows, 15, '1 (header) + 14 (updates) = 15 lines';
+ is scalar @rows, 18, '1 (header) + 17 (updates) = 18 lines';
is scalar @{$rows[0]}, 8, '8 columns present';
is_deeply $rows[0],