diff options
Diffstat (limited to 'perllib/Open311')
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 11 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 12 |
2 files changed, 12 insertions, 11 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 875769eac..27cb21c3a 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -31,7 +31,7 @@ sub fetch { jurisdiction => $body->jurisdiction, ); - if ( $body->area_id == 2482 ) { + if ( $body->areas->{2482} ) { my $endpoints = $o->endpoints; $endpoints->{update} = 'update.xml'; $endpoints->{service_request_updates} = 'update.xml'; @@ -40,7 +40,7 @@ sub fetch { $self->suppress_alerts( $body->suppress_alerts ); $self->system_user( $body->comment_user ); - $self->update_comments( $o, { areaid => $body->area_id }, ); + $self->update_comments( $o, { areas => $body->areas }, ); } } @@ -55,7 +55,7 @@ sub update_comments { push @args, $self->start_date; push @args, $self->end_date; # default to asking for last 2 hours worth if not Bromley - } elsif ( $body_details->{areaid} != 2482 ) { + } elsif ( ! $body_details->{areas}->{2482} ) { my $end_dt = DateTime->now(); my $start_dt = $end_dt->clone; $start_dt->add( hours => -2 ); @@ -67,7 +67,7 @@ sub update_comments { my $requests = $open311->get_service_request_updates( @args ); unless ( $open311->success ) { - warn "Failed to fetch ServiceRequest Updates for " . $body_details->{areaid} . ":\n" . $open311->error + warn "Failed to fetch ServiceRequest Updates for " . join(",", keys %{$body_details->{areas}}) . ":\n" . $open311->error if $self->verbose; return 0; } @@ -83,7 +83,8 @@ sub update_comments { FixMyStreet::App->model('DB::Problem') ->search( { external_id => $request_id, - bodies_str => { like => '%' . $body_details->{areaid} . '%' }, + # XXX This assumes that areas will actually only be one area. + bodies_str => { like => '%' . join(",", keys %{$body_details->{areas}}) . '%' }, } ); if (my $p = $problem->first) { diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index 8000378e3..bd90e10e9 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -42,8 +42,8 @@ sub process_body { my $list = $open311->get_service_list; unless ( $list ) { my $id = $self->_current_body->id; - my $area_id = $self->_current_body->area_id; - warn "Body $id for area $area_id - http://mapit.mysociety.org/area/$area_id.html - did not return a service list\n" + my $areas = join( ",", keys %{$self->_current_body->areas} ); + warn "Body $id for areas $areas - http://mapit.mysociety.org/areas/$areas.html - did not return a service list\n" if $self->verbose >= 1; return; } @@ -56,7 +56,7 @@ sub _check_endpoints { my $self = shift; # west berks end point not standard - if ( $self->_current_body->area_id == 2619 ) { + if ( $self->_current_body->areas->{2619} ) { $self->_current_open311->endpoints( { services => 'Services', @@ -82,7 +82,7 @@ sub process_services { sub process_service { my $self = shift; - my $category = $self->_current_body->area_id == 2218 ? + my $category = $self->_current_body->areas->{2218} ? $self->_current_service->{description} : $self->_current_service->{service_name}; @@ -226,7 +226,7 @@ sub _add_meta_to_contact { # we add these later on from bromley so don't list them here # as we don't want to display them - if ( $self->_current_body->area_id == 2482 ) { + if ( $self->_current_body->areas->{2482} ) { my %ignore = map { $_ => 1 } qw/ service_request_id_ext requested_datetime @@ -257,7 +257,7 @@ sub _normalize_service_name { # FIXME - at the moment it makes more sense to use the description # for cambridgeshire but need a more flexible way to set this - my $service_name = $self->_current_body->area_id == 2218 ? + my $service_name = $self->_current_body->areas->{2218} ? $self->_current_service->{description} : $self->_current_service->{service_name}; # remove trailing whitespace as it upsets db queries |