aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm12
-rwxr-xr-xtemplates/web/base/reports/index.html13
3 files changed, 18 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index c03f5d9c8..0e42b8a17 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -5,9 +5,7 @@ use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller'; }
use FixMyStreet::Map;
-use List::MoreUtils qw(any);
use Encode;
-use FixMyStreet::Map;
use Utils;
=head1 NAME
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(
diff --git a/templates/web/base/reports/index.html b/templates/web/base/reports/index.html
index 1e4130a37..7f8d7fbf6 100755
--- a/templates/web/base/reports/index.html
+++ b/templates/web/base/reports/index.html
@@ -1,11 +1,16 @@
-[% INCLUDE 'header.html', title = loc('Summary reports'), bodyclass => 'fullwidthpage' %]
+[% INCLUDE 'header.html', title = loc('Summary reports'), bodyclass => 'fullwidthpage' %]
<h1>[% loc('All Reports') %]</h1>
<div class="intro">
<p>
-[% loc('This is a summary of all reports on this site; select a particular council to see the reports sent there.') %]
-[% loc('Greyed-out lines are councils that no longer exist.') %]
+ [% loc('This is a summary of all reports on this site.') %]
+ [% IF bodies.size > 1 %]
+ [% loc('Select a particular council to see the reports sent there.') %]
+ [% END %]
+ [% IF any_empty_bodies %]
+ [% loc('Greyed-out lines are councils that no longer exist.') %]
+ [% END %]
</p>
</div>
@@ -24,7 +29,7 @@
<tbody>
[% FOREACH body IN bodies %]
<tr align="center"
-[%- IF NOT body.areas.size %] class="gone"
+[%- IF NOT body.get_column("area_count") %] class="gone"
[%- ELSIF ! (loop.count % 2) %] class="a"
[%- END %]>
<td class="title"><a href="[% body.url(c) %]">[% body.name %]</a></td>