aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Reports.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2014-11-12 17:20:37 +0000
committerMatthew Somerville <matthew@mysociety.org>2014-11-14 22:48:56 +0000
commit57fcd59af03f823528f71c03c8f8043f4fee63ca (patch)
tree02fc01165077b85b960dc7a5727bcd07fe05df1d /perllib/FixMyStreet/App/Controller/Reports.pm
parent731419689b71b39619fc82b2d833e7830ba3b192 (diff)
Only show text on /reports if appropriate.
Only show "select..." if more than one body, and only mention greyed out lines if there are any. Fixes #869.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Reports.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 6f38ec101..2c4f73df3 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -3,7 +3,7 @@ use Moose;
use namespace::autoclean;
use File::Slurp;
-use List::MoreUtils qw(zip);
+use List::MoreUtils qw(any);
use POSIX qw(strcoll);
use RABX;
use mySociety::MaPit;
@@ -52,10 +52,16 @@ sub index : Path : Args(0) {
$c->detach( 'redirect_body' );
}
- # Fetch all areas of the types we're interested in
- my @bodies = $c->model('DB::Body')->all;
+ # Fetch all bodies
+ my @bodies = $c->model('DB::Body')->search({}, {
+ '+select' => [ { count => 'area_id' } ],
+ '+as' => [ 'area_count' ],
+ join => 'body_areas',
+ distinct => 1,
+ })->all;
@bodies = sort { strcoll($a->name, $b->name) } @bodies;
$c->stash->{bodies} = \@bodies;
+ $c->stash->{any_empty_bodies} = any { $_->get_column('area_count') == 0 } @bodies;
eval {
my $data = File::Slurp::read_file(