diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/send-comments | 20 | ||||
-rwxr-xr-x | bin/update-all-reports | 28 |
2 files changed, 24 insertions, 24 deletions
diff --git a/bin/send-comments b/bin/send-comments index caf4b8b91..7520af17d 100755 --- a/bin/send-comments +++ b/bin/send-comments @@ -1,7 +1,7 @@ #!/usr/bin/env perl # send-reports: -# Send new problem reports to councils +# Send new problem reports to bodies # # Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org @@ -35,12 +35,12 @@ my ($verbose, $nomail) = CronFns::options(); my $base_url = mySociety::Config::get('BASE_URL'); my $site = CronFns::site($base_url); -my $councils = FixMyStreet::App->model('DB::Body')->search( { +my $bodies = FixMyStreet::App->model('DB::Body')->search( { send_method => SEND_METHOD_OPEN311, send_comments => 1, } ); -while ( my $council = $councils->next ) { +while ( my $body = $bodies->next ) { my $use_extended = 0; my $comments = FixMyStreet::App->model('DB::Comment')->search( { 'me.whensent' => undef, @@ -49,7 +49,7 @@ while ( my $council = $councils->next ) { 'me.confirmed' => { '!=' => undef }, 'problem.whensent' => { '!=' => undef }, 'problem.external_id' => { '!=' => undef }, - 'problem.council' => { -like => '%' . $council->area_id .'%' }, + 'problem.bodies_str' => { -like => '%' . $body->area_id .'%' }, 'problem.send_method_used' => 'Open311', }, { @@ -57,18 +57,18 @@ while ( my $council = $councils->next ) { } ); - if ( $council->area_id == 2482 ) { + if ( $body->area_id == 2482 ) { $use_extended = 1; } my $o = Open311->new( - endpoint => $council->endpoint, - jurisdiction => $council->jurisdiction, - api_key => $council->api_key, + endpoint => $body->endpoint, + jurisdiction => $body->jurisdiction, + api_key => $body->api_key, use_extended_updates => $use_extended, ); - if ( $council->area_id =~ /2482/ ) { + if ( $body->area_id == 2482 ) { my $endpoints = $o->endpoints; $endpoints->{update} = 'update.xml'; $endpoints->{service_request_updates} = 'update.xml'; @@ -82,7 +82,7 @@ while ( my $council = $councils->next ) { next if bromley_retry_timeout( $comment ); } - if ( $council->area_id == 2482 ) { + if ( $body->area_id == 2482 ) { my $extra = $comment->extra; if ( !$extra ) { $extra = {}; diff --git a/bin/update-all-reports b/bin/update-all-reports index 4c4838c77..e9edae0af 100755 --- a/bin/update-all-reports +++ b/bin/update-all-reports @@ -24,7 +24,7 @@ my $problems = FixMyStreet::App->model("DB::Problem")->search( }, { columns => [ - 'id', 'council', 'state', 'areas', + 'id', 'bodies_str', 'state', 'areas', { duration => { extract => "epoch from current_timestamp-lastupdate" } }, { age => { extract => "epoch from current_timestamp-confirmed" } }, ] @@ -33,31 +33,31 @@ my $problems = FixMyStreet::App->model("DB::Problem")->search( $problems = $problems->cursor; # Raw DB cursor for speed my ( %fixed, %open ); -my @cols = ( 'id', 'council', 'state', 'areas', 'duration', 'age' ); +my @cols = ( 'id', 'bodies_str', 'state', 'areas', 'duration', 'age' ); while ( my @problem = $problems->next ) { my %problem = zip @cols, @problem; - my @areas; - if ( !$problem{council} ) { - # Problem was not sent to any council, add to all areas - @areas = grep { $_ } split( /,/, $problem{areas} ); - $problem{councils} = 0; + my @bodies; + if ( !$problem{bodies_str} ) { + # Problem was not sent to any bodies, add to all areas + @bodies = grep { $_ } split( /,/, $problem{areas} ); + $problem{bodies} = 0; } else { - # Add to councils it was sent to - (my $council = $problem{council}) =~ s/\|.*$//; - @areas = split( /,/, $council ); - $problem{councils} = scalar @areas; + # Add to bodies it was sent to + (my $bodies = $problem{bodies_str}) =~ s/\|.*$//; + @bodies = split( /,/, $bodies ); + $problem{bodies} = scalar @bodies; } - foreach my $council ( @areas ) { + foreach my $body ( @bodies ) { my $duration_str = ( $problem{duration} > 2 * $fourweeks ) ? 'old' : 'new'; my $type = ( $problem{duration} > 2 * $fourweeks ) ? 'unknown' : ($problem{age} > $fourweeks ? 'older' : 'new'); if (FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}}) { # Fixed problems are either old or new - $fixed{$council}{$duration_str}++ if FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}}; + $fixed{$body}{$duration_str}++ if FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}}; } else { # Open problems are either unknown, older, or new - $open{$council}{$type}++ if $problem{state} eq 'confirmed'; + $open{$body}{$type}++ if $problem{state} eq 'confirmed'; } } } |