aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Reports.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2018-05-29 19:37:34 +0200
committerMarius Halden <marius.h@lden.org>2018-05-29 19:37:34 +0200
commit782457d016084c8de04989dbc824a71899f8b41b (patch)
tree56d14e1a988396e43c8693ff3486e40d16962add /perllib/FixMyStreet/App/Controller/Reports.pm
parent140d40e3eab4cb1e7aa9f95cbc24a0f13180b606 (diff)
parent6e2da95bc6a758c0cf070b9ddd51acc769f7acf1 (diff)
Merge tag 'v2.3.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Reports.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm22
1 files changed, 4 insertions, 18 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index ec7a192b3..7c3796c42 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -5,7 +5,6 @@ use namespace::autoclean;
use JSON::MaybeXS;
use List::MoreUtils qw(any);
use Path::Tiny;
-use POSIX qw(strcoll);
use RABX;
use mySociety::MaPit;
@@ -93,18 +92,8 @@ sub index : Path : Args(0) {
$c->stash->{children} = $children;
}
} else {
- # Fetch all bodies
- my @bodies = $c->model('DB::Body')->search({
- deleted => 0,
- }, {
- '+select' => [ { count => 'area_id' } ],
- '+as' => [ 'area_count' ],
- join => 'body_areas',
- distinct => 1,
- })->all;
- @bodies = sort { strcoll($a->name, $b->name) } @bodies;
+ my @bodies = $c->model('DB::Body')->active->translated->with_area_count->all_sorted;
$c->stash->{bodies} = \@bodies;
- $c->stash->{any_empty_bodies} = any { $_->get_column('area_count') == 0 } @bodies;
}
# Down here so that error pages aren't cached.
@@ -451,16 +440,13 @@ sub summary : Private {
# required to stop errors in generate_grouped_data
$c->stash->{q_state} = '';
- $c->stash->{ward} = $c->get_param('ward');
+ $c->stash->{ward} = $c->get_param('area');
$c->stash->{start_date} = $dtf->format_date($start_date);
$c->stash->{end_date} = $c->get_param('end_date');
$c->stash->{group_by_default} = 'category';
- my $area_id = $c->stash->{body}->body_areas->first->area_id;
- my $children = mySociety::MaPit::call('area/children', $area_id,
- type => $c->cobrand->area_types_children,
- );
+ my $children = $c->stash->{body}->first_area_children;
$c->stash->{children} = $children;
$c->forward('/admin/fetch_contacts');
@@ -508,7 +494,7 @@ sub export_summary_csv : Private {
'postcode',
'url',
],
- filename => 'fixmystreet-data.csv',
+ filename => 'fixmystreet-data',
};
$c->forward('/dashboard/generate_csv');
}