aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2014-03-24 11:59:40 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2014-04-07 17:49:58 +0100
commitb0170c4be0c2c3befcbe0159d4e218db5e0e37a8 (patch)
tree8f10f2a215fe1a6e7548e20ed535ce06339279a7 /perllib
parent8f8d5e017e34a0b68a4b9c5c6958c827dcb6a172 (diff)
Update old-style open311 script to use bodies.
Add some comments to the top of the open311 bin scripts.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm20
-rw-r--r--perllib/Open311/GetUpdates.pm22
2 files changed, 20 insertions, 22 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index a06a339bf..7b5460c51 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -436,7 +436,7 @@ sub bodies_str_ids {
=head2 bodies
-Returns an arrayref of bodies to which a report was sent.
+Returns a hashref of bodies to which a report was sent.
=cut
@@ -678,13 +678,16 @@ sub local_coords {
=head2 update_from_open311_service_request
- $p->update_from_open311_service_request( $request, $council_details, $system_user );
+ $p->update_from_open311_service_request( $request, $body, $system_user );
-Updates the problem based on information in the passed in open311 request. If the request
-has an older update time than the problem's lastupdate time then nothing happens.
+Updates the problem based on information in the passed in open311 request
+(standard, not the extension that uses GetServiceRequestUpdates) . If the
+request has an older update time than the problem's lastupdate time then
+nothing happens.
-Otherwise a comment will be created if there is status update text in the open311 request.
-If the open311 request has a state of closed then the problem will be marked as fixed.
+Otherwise a comment will be created if there is status update text in the
+open311 request. If the open311 request has a state of closed then the problem
+will be marked as fixed.
NB: a comment will always be created if the problem is being marked as fixed.
@@ -693,7 +696,7 @@ Fixed problems will not be re-opened by this method.
=cut
sub update_from_open311_service_request {
- my ( $self, $request, $council_details, $system_user ) = @_;
+ my ( $self, $request, $body, $system_user ) = @_;
my ( $updated, $status_notes );
@@ -716,11 +719,10 @@ sub update_from_open311_service_request {
mark_fixed => 0,
user => $system_user,
anonymous => 0,
- name => $council_details->{name},
+ name => $body->name,
}
);
-
my $w3c = DateTime::Format::W3CDTF->new;
my $req_time = $w3c->parse_datetime( $request->{updated_datetime} );
diff --git a/perllib/Open311/GetUpdates.pm b/perllib/Open311/GetUpdates.pm
index 7441f7f6d..5007a1f82 100644
--- a/perllib/Open311/GetUpdates.pm
+++ b/perllib/Open311/GetUpdates.pm
@@ -4,26 +4,22 @@ use Moose;
use Open311;
use FixMyStreet::App;
-has council_list => ( is => 'ro' );
+has body_list => ( is => 'ro' );
has system_user => ( is => 'ro' );
sub get_updates {
my $self = shift;
- while ( my $council = $self->council_list->next ) {
+ while ( my $body = $self->body_list->next ) {
my $open311 = Open311->new(
- endpoint => $council->endpoint,
- jurisdiction => $council->jurisdiction,
- api_key => $council->api_key
+ endpoint => $body->endpoint,
+ jurisdiction => $body->jurisdiction,
+ api_key => $body->api_key
);
- my $area_id = $council->area_id;
-
- my $council_details = mySociety::MaPit::call( 'area', $area_id );
-
my $reports = FixMyStreet::App->model('DB::Problem')->search(
{
- council => { like => "\%$area_id\%" },
+ bodies_str => { like => "\%" . $body->id . "\%" },
state => { 'IN', [qw/confirmed fixed/] },
-and => [
external_id => { '!=', undef },
@@ -39,12 +35,12 @@ sub get_updates {
next unless @report_ids;
- $self->update_reports( \@report_ids, $open311, $council_details );
+ $self->update_reports( \@report_ids, $open311, $body );
}
}
sub update_reports {
- my ( $self, $report_ids, $open311, $council_details ) = @_;
+ my ( $self, $report_ids, $open311, $body ) = @_;
my $service_requests = $open311->get_service_requests( $report_ids );
@@ -74,7 +70,7 @@ sub update_reports {
if (my $p = $problem->first) {
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($p->cobrand)->new();
$cobrand->set_lang_and_domain($p->lang, 1, FixMyStreet->path_to('locale')->stringify );
- $p->update_from_open311_service_request( $request, $council_details, $self->system_user );
+ $p->update_from_open311_service_request( $request, $body, $self->system_user );
}
}