From 552805bd5653504a6795ce024d5c40a8a5a44bf3 Mon Sep 17 00:00:00 2001 From: joeyisking Date: Thu, 3 Dec 2015 09:39:03 +1100 Subject: Also store all reports summary data by cobrand. This adds the ability to e.g. limit the all reports page by cobrand. --- bin/update-all-reports | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/update-all-reports b/bin/update-all-reports index 25405e8ad..60da837e9 100755 --- a/bin/update-all-reports +++ b/bin/update-all-reports @@ -40,7 +40,7 @@ my $problems = FixMyStreet::DB->resultset('Problem')->search( }, { columns => [ - 'id', 'bodies_str', 'state', 'areas', + 'id', 'bodies_str', 'state', 'areas', 'cobrand', { duration => { extract => "epoch from current_timestamp-lastupdate" } }, { age => { extract => "epoch from current_timestamp-$age_column" } }, ] @@ -49,10 +49,12 @@ my $problems = FixMyStreet::DB->resultset('Problem')->search( $problems = $problems->cursor; # Raw DB cursor for speed my ( %fixed, %open ); -my @cols = ( 'id', 'bodies_str', 'state', 'areas', 'duration', 'age' ); +my @cols = ( 'id', 'bodies_str', 'state', 'areas', 'cobrand', 'duration', 'age' ); while ( my @problem = $problems->next ) { my %problem = zip @cols, @problem; my @bodies; + my $cobrand = $problem{cobrand}; + if ( !$problem{bodies_str} ) { # Problem was not sent to any bodies, add to all areas @bodies = grep { $_ } split( /,/, $problem{areas} ); @@ -70,9 +72,11 @@ while ( my @problem = $problems->next ) { if (FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}} || FixMyStreet::DB::Result::Problem->closed_states()->{$problem{state}}) { # Fixed problems are either old or new $fixed{$body}{$duration_str}++; + $fixed{$cobrand}{$body}{$duration_str}++; } else { # Open problems are either unknown, older, or new $open{$body}{$type}++; + $open{$cobrand}{$body}{$type}++; } } } -- cgit v1.2.3