diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-01-02 12:25:50 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-01-03 14:22:30 +0000 |
commit | c900b5057c6d3a9c389a0d0ac8524ab2e3abd8f8 (patch) | |
tree | 02b49c7f2705ae733b7a12006c60a235fb5ebf27 /perllib/FixMyStreet/App/Controller/Reports.pm | |
parent | 39e549b3e1978cc5d6b29ba37f57ca90d3c391cb (diff) |
Add some new Body model helper methods.
And use the existing ones more.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Reports.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index ec7a192b3..315cfc074 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->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. @@ -457,10 +446,7 @@ sub summary : Private { $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'); |