diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-13 15:48:48 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:06 +0000 |
commit | 9fb130a0ab1bd36e977439b7697fba5fec5b1f00 (patch) | |
tree | e9c8f3fce2ecf110172b9359e48c436b10e66fee /perllib/FixMyStreet/App/Controller/Open311.pm | |
parent | 48d290abd549a623e3af4b62127668cf92018d9c (diff) |
Rename council column to bodies_str, and all the related code.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Open311.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index b1e685c1c..62cdaffaf 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -164,11 +164,11 @@ sub get_services : Private { if ($lat || $lon) { my $area_types = $c->cobrand->area_types; - my $all_councils = mySociety::MaPit::call('point', + my $all_areas = mySociety::MaPit::call('point', "4326/$lon,$lat", type => $area_types); $categories = $categories->search( { - 'body.area_id' => [ keys %$all_councils ], + 'body.area_id' => [ keys %$all_areas ], }, { join => 'body' } ); } @@ -223,19 +223,11 @@ sub output_requests : Private { ); my @problemlist; - my @councils; while ( my $problem = $problems->next ) { my $id = $problem->id; $problem->service( 'Web interface' ) unless $problem->service; - if ($problem->council) { - (my $council = $problem->council) =~ s/\|.*//g; - my @council_ids = split(/,/, $council); - push(@councils, @council_ids); - $problem->council( \@council_ids ); - } - $problem->state( $statusmap{$problem->state} ); my $request = @@ -256,7 +248,7 @@ sub output_requests : Private { 'service_code' => [ $problem->category ], 'service_name' => [ $problem->category ], # 'service_notice' => [ {} ], - 'agency_responsible' => $problem->council , # FIXME Not according to Open311 v2 + 'agency_responsible' => $problem->bodies , # FIXME Not according to Open311 v2 # 'zipcode' => [ {} ], 'interface_used' => [ $problem->service ], # Not in Open311 v2 }; @@ -288,12 +280,12 @@ sub output_requests : Private { } push(@problemlist, $request); } - my $areas_info = mySociety::MaPit::call('areas', \@councils); + foreach my $request (@problemlist) { if ($request->{agency_responsible}) { - my @council_names = map { $areas_info->{$_}->{name} } @{$request->{agency_responsible}} ; + my @body_names = map { $_->name } values %{$request->{agency_responsible}} ; $request->{agency_responsible} = - [ {'recipient' => [ @council_names ] } ]; + [ {'recipient' => [ @body_names ] } ]; } } $c->forward( 'format_output', [ { @@ -319,7 +311,7 @@ sub get_requests : Private { service_request_id => [ '=', 'id' ], service_code => [ '=', 'category' ], status => [ 'IN', 'state' ], - agency_responsible => [ '~', 'council' ], + agency_responsible => [ '~', 'bodies_str' ], interface_used => [ '=', 'service' ], has_photo => [ '=', 'photo' ], ); |