diff options
author | Struan Donald <struan@exo.org.uk> | 2012-03-28 16:52:01 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-03-28 16:52:01 +0100 |
commit | 927e8b24e6c1cbb3a0114e14d2d61a0891dca082 (patch) | |
tree | e53fa7ac45f1905bec426fa96b14be0a08969b8a /perllib/Open311 | |
parent | 46592020068908e41ae1d20c04a9080bb6a4a0da (diff) |
push comment fetching code into module so script is a thin wrapper
Diffstat (limited to 'perllib/Open311')
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index ed483cfd8..ac06dc03e 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -6,10 +6,35 @@ use FixMyStreet::App; use DateTime::Format::W3CDTF; has council_list => ( is => 'ro' ); -has system_user => ( is => 'ro' ); +has system_user => ( is => 'rw' ); has start_date => ( is => 'ro', default => undef ); has end_date => ( is => 'ro', default => undef ); +sub fetch { + my $self = shift; + + my $councils = FixMyStreet::App->model('DB::Open311Conf')->search( + { + 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, + ); + + $self->system_user( $council->comment_user ); + $self->update_comments( $o, { areaid => $council->area_id }, ); + } +} + sub update_comments { my ( $self, $open311, $council_details ) = @_; |