aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/Reading.pm29
-rw-r--r--templates/web/reading/reports/cobrand_stats.html5
4 files changed, 42 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 0a4ae4609..0587a627a 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -110,6 +110,8 @@ sub ward : Path : Args(2) {
$c->stash->{council_url} = '/reports/' . $council_short;
+ $c->stash->{stats} = $c->cobrand->get_report_stats();
+
my $pins = $c->stash->{pins};
$c->stash->{page} = 'reports'; # So the map knows to make clickable pins
@@ -349,17 +351,12 @@ sub load_and_group_problems : Private {
$c->stash->{pager} = $problems->pager;
$problems = $problems->cursor; # Raw DB cursor for speed
- my ( %fixed, %open, @pins, $total, $cobrand_total );
+ my ( %fixed, %open, @pins );
my $re_councils = join('|', keys %{$c->stash->{areas_info}});
my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'duration', 'age' );
while ( my @problem = $problems->next ) {
my %problem = zip @cols, @problem;
$c->log->debug( $problem{'cobrand'} . ', cobrand is ' . $c->cobrand->moniker );
- if ( $problem{'cobrand'} && $problem{'cobrand'} eq $c->cobrand->moniker ) {
- $cobrand_total++;
- } else {
- $total++;
- }
if ( !$problem{council} ) {
# Problem was not sent to any council, add to possible councils
$problem{councils} = 0;
@@ -382,8 +379,6 @@ sub load_and_group_problems : Private {
fixed => \%fixed,
open => \%open,
pins => \@pins,
- cobrand_count => $cobrand_total || 0,
- total_count => $total || 0,
);
return 1;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 1e87468ac..2900497c4 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -960,5 +960,13 @@ to be resized then return 0;
sub default_photo_resize { return 0; }
+=head2 get_report_stats
+
+Get stats to display on the council reports page
+
+=cut
+
+sub get_report_stats { return 0; }
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Reading.pm b/perllib/FixMyStreet/Cobrand/Reading.pm
index f4fd0dc7a..8e98931fd 100644
--- a/perllib/FixMyStreet/Cobrand/Reading.pm
+++ b/perllib/FixMyStreet/Cobrand/Reading.pm
@@ -77,5 +77,32 @@ sub recent_photos {
return $self->problems->recent_photos( $num, $lat, $lon, $dist );
}
-1;
+sub get_report_stats {
+ my $self = shift;
+
+ my ( $cobrand, $main_site ) = ( 0, 0 );
+
+ $self->{c}->log->debug( 'X' x 60 );
+ my $stats = $self->{c}->model('DB::Problem')->search(
+ { confirmed => { '>=', '2011-11-01' } },
+ {
+ select => [ { count => 'id', -as => 'cobrand_count' }, 'cobrand' ],
+ group_by => [qw/cobrand/]
+ }
+ );
+
+ while ( my $stat = $stats->next ) {
+ if ( $stat->cobrand eq $self->moniker ) {
+ $cobrand += $stat->get_column( 'cobrand_count' );
+ } else {
+ $main_site += $stat->get_column( 'cobrand_count' );
+ }
+ }
+ return {
+ cobrand => $cobrand,
+ main_site => $main_site,
+ };
+}
+
+1;
diff --git a/templates/web/reading/reports/cobrand_stats.html b/templates/web/reading/reports/cobrand_stats.html
index becb724cf..80976c3a6 100644
--- a/templates/web/reading/reports/cobrand_stats.html
+++ b/templates/web/reading/reports/cobrand_stats.html
@@ -1,4 +1,5 @@
<ul>
- <li>Reports submitted via <a href="[% uri_for('/') %]">reading.fixmystreet.com</a>: [% cobrand_count %]</li>
- <li>Reports submitted via <a href="http://www.fixmystreet.com/">www.fixmystreet.com</a>: [% total_count %]</li>
+ <li>Reports submitted via <a href="[% uri_for('/') %]">reading.fixmystreet.com</a>: [% stats.cobrand %]</li>
+ <li>Reports submitted via <a href="http://www.fixmystreet.com/">www.fixmystreet.com</a>: [% stats.main_site %]<br /><br />
+ Statistics date from launch of Reading FixMyStreet.</li>
</ul>