diff options
author | joeyisking <joeyisking@users.noreply.github.com> | 2015-12-03 09:39:03 +1100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-12-04 12:31:37 +0000 |
commit | 552805bd5653504a6795ce024d5c40a8a5a44bf3 (patch) | |
tree | eb668e4ce64cadc8b913c50a57a3d03b0170cee4 | |
parent | 0c9e00d52568843b1f4c3e8b02b9e47eccceb6ea (diff) |
Also store all reports summary data by cobrand.
This adds the ability to e.g. limit the all reports page by cobrand.
-rwxr-xr-x | bin/update-all-reports | 8 |
1 files changed, 6 insertions, 2 deletions
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}++; } } } |