diff options
author | Struan Donald <struan@exo.org.uk> | 2012-03-26 17:36:12 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-03-26 17:36:12 +0100 |
commit | c06944b854f20a9887c3ecc9a5b2d33e98f061f0 (patch) | |
tree | 4d2b7d246b9bd880b07aaf8a8a69db17d719fef9 /bin/fetch-comments | |
parent | 23f700258100bfc42c8b07c251f8582399824409 (diff) |
initial fetch comment wrapper script
Diffstat (limited to 'bin/fetch-comments')
-rwxr-xr-x | bin/fetch-comments | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/fetch-comments b/bin/fetch-comments new file mode 100755 index 000000000..e0e53826e --- /dev/null +++ b/bin/fetch-comments @@ -0,0 +1,58 @@ +#!/usr/bin/env perl + +# send-reports: +# Send new problem reports to councils +# +# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org + +use strict; +use warnings; +require 5.8.0; + +use Digest::MD5; +use Encode; +use Error qw(:try); +use CronFns; + +use FixMyStreet::App; + +use Utils; +use mySociety::Config; +use mySociety::EmailUtil; + +use Open311; +use Open311::GetServiceRequestUpdates; + +# send_method config values found in by-area config data, for selecting to appropriate method +use constant SEND_METHOD_EMAIL => 'email'; +use constant SEND_METHOD_OPEN311 => 'open311'; + +# Set up site, language etc. +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::Open311Conf')->search( + { + send_method => SEND_METHOD_OPEN311, + send_comments => 1, + comment_user_id => { '!=', undef }, + endpoint => { '!=', '' }, + } +); + +while ( my $council = $councils->next ) { + + my $o = Open311->new( + endpoint => $council->endpoint, + api_key => $council->api_key, + jurisdiction => $council->jurisdiction, + ); + + my $updates = + Open311::GetServiceRequestUpdates->new( + system_user => $council->comment_user ); + + $updates->update_comments( $o, { areaid => $council->area_id }, ); +} |