aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-08-10 17:52:53 +0100
committerStruan Donald <struan@exo.org.uk>2011-08-10 17:52:53 +0100
commit94b3e2ebcd5a972bf72f62e2770d1a9a11c8ff24 (patch)
treebce91fd1573972ea103d07b049b573d031bfce15
parent0ab214144fc2774171c35f89361d55e7b006205c (diff)
break down problems into states for a bit more clarity
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm8
-rw-r--r--templates/web/default/admin/stats.html28
2 files changed, 34 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index af87e39fd..141aa516d 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -802,12 +802,18 @@ sub stats : Path('stats') : Args(0) {
$field => { '>=', $start_date->ymd },
$field => { '<=', $end_date->ymd },
],
+ },
+ {
+ select => [ 'state', { 'count' => 'me.id' } ],
+ as => [qw/state count/],
+ group_by => [ 'state' ],
+ order_by => [ 'state' ],
}
);
# in case the total_report count is 0
$c->stash->{show_count} = 1;
- $c->stash->{total_reports} = $p->count;
+ $c->stash->{states} = $p;
}
return 1;
diff --git a/templates/web/default/admin/stats.html b/templates/web/default/admin/stats.html
index 17776c41c..07a464c47 100644
--- a/templates/web/default/admin/stats.html
+++ b/templates/web/default/admin/stats.html
@@ -1,7 +1,33 @@
[% INCLUDE 'admin/header.html' title=loc('Stats') %]
[% IF show_count %]
-<strong>[% tprintf( loc( 'Total %sreports between %s and %s: %d' ), ( unconfirmed ? '' : loc( 'confirmed' ) _ ' ' ), start_date.ymd, end_date.ymd, total_reports ) | html %]</strong>
+<p>
+<strong>[% tprintf( loc( '%sReports between %s and %s' ), ( unconfirmed ? '' : loc( 'Confirmed' ) _ ' ' ), start_date.ymd, end_date.ymd ) | html %]</strong>
+</p>
+<table>
+ <thead>
+ <td style="width: 8em"><strong>[% loc('State') %]</strong></td>
+ <td><strong>[% loc('Count') %]</strong></td>
+ </thead>
+ [% total = 0 %]
+ [% WHILE ( state = states.next ) %]
+ [% total = total + state.get_column( 'count' ) %]
+ <tr>
+ <td>[% state.state | html %]</td>
+ <td>[% state.get_column( 'count' ) %]</td>
+ </tr>
+ [% END %]
+ <tr>
+ <td><strong>[% loc( 'Total' ) %]</strong></td>
+ <td><strong>[% total %]</strong></td>
+ </tr>
+</table>
+
+[% IF unconfirmed %]
+ <p>
+ <small>[% loc( 'Note that when including unconfirmed reports we use the date the report was created which may not be in the same month the report was confirmed so the numbers may jump about a little' ) %]</small>
+ </p>
+[% END %]
[% END %]
[% IF errors %]