aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2017-09-05 16:33:26 +0100
committerStruan Donald <struan@exo.org.uk>2017-09-05 16:33:26 +0100
commit78dd21a18c6c4e95a267c07eb92f07dbc5b1f48e (patch)
treee5d85bddc916562bf50a8b0116e11e7ce2cbc292
parent8ad343eb7d2bfbee4db0ad1bb49c5480b458e262 (diff)
parent1391186c2fb56e46df5b124362e3facf6af173b5 (diff)
Merge branch 'issues/forcouncils/220-ward-column-in-export'
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm13
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm1
-rw-r--r--t/app/controller/dashboard.t31
3 files changed, 45 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index f3989e760..867d0659b 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -212,6 +212,9 @@ sub export_as_csv {
'Status',
'Latitude', 'Longitude',
'Nearest Postcode',
+ 'Ward',
+ 'Easting',
+ 'Northing',
'Report URL',
);
my @body = ($csv->string);
@@ -243,6 +246,13 @@ sub export_as_csv {
}
}
+ my $wards = join ', ',
+ map { $c->stash->{children}->{$_}->{name} }
+ grep {$c->stash->{children}->{$_} }
+ split ',', $hashref->{areas};
+
+ my @local_coords = $report->local_coords;
+
$csv->combine(
@{$hashref}{
'id',
@@ -259,6 +269,9 @@ sub export_as_csv {
'latitude', 'longitude',
'postcode',
},
+ $wards,
+ $local_coords[0],
+ $local_coords[1],
(join '', $c->cobrand->base_url_for_report($report), $report->url),
);
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 77190679b..3b622b561 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -861,6 +861,7 @@ sub as_hashref {
latitude => $self->latitude,
longitude => $self->longitude,
postcode => $self->postcode,
+ areas => $self->areas,
state => $self->state,
state_t => _( $self->state ),
used_map => $self->used_map,
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index b87b58b38..5c0e19070 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -593,6 +593,7 @@ FixMyStreet::override_config {
detail => "this report\nis split across\nseveral lines",
state => "confirmed",
conf_dt => DateTime->now(),
+ areas => 62883,
} );
$mech->get_ok('/dashboard?export=1');
open my $data_handle, '<', \$mech->content;
@@ -602,6 +603,36 @@ FixMyStreet::override_config {
push @rows, $row;
}
is scalar @rows, 6, '1 (header) + 5 (reports) = 6 lines';
+
+ is scalar @{$rows[0]}, 18, '18 columns present';
+
+ is_deeply $rows[0],
+ [
+ 'Report ID',
+ 'Title',
+ 'Detail',
+ 'User Name',
+ 'Category',
+ 'Created',
+ 'Confirmed',
+ 'Acknowledged',
+ 'Fixed',
+ 'Closed',
+ 'Status',
+ 'Latitude',
+ 'Longitude',
+ 'Nearest Postcode',
+ 'Ward',
+ 'Easting',
+ 'Northing',
+ 'Report URL',
+ ],
+ 'Column headers look correct';
+
+ is $rows[5]->[14], 'Bradford-on-Avon', 'Ward column is name not ID';
+
+ is $rows[5]->[15], '610591', 'Correct Easting conversion';
+ is $rows[5]->[16], '126573', 'Correct Northing conversion';
};
};
restore_time;