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/JSON.pm | |
parent | 48d290abd549a623e3af4b62127668cf92018d9c (diff) |
Rename council column to bodies_str, and all the related code.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/JSON.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/JSON.pm | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm index f3607341a..1a7c1915b 100644 --- a/perllib/FixMyStreet/App/Controller/JSON.pm +++ b/perllib/FixMyStreet/App/Controller/JSON.pm @@ -92,7 +92,7 @@ sub problems : Local { my @problems = $c->cobrand->problems->search( $query, { order_by => { -asc => 'confirmed' }, columns => [ - 'id', 'title', 'council', 'category', + 'id', 'title', 'bodies_str', 'category', 'detail', 'name', 'anonymous', 'confirmed', 'whensent', 'service', 'latitude', 'longitude', 'used_map', @@ -100,23 +100,13 @@ sub problems : Local { ] } ); - my @councils; foreach my $problem (@problems) { $problem->name( '' ) if $problem->anonymous == 1; $problem->service( 'Web interface' ) if $problem->service eq ''; - if ($problem->council) { - (my $council = $problem->council) =~ s/\|.*//g; - my @council_ids = split /,/, $council; - push(@councils, @council_ids); - $problem->council( \@council_ids ); - } - } - @councils = uniq @councils; - my $areas_info = mySociety::MaPit::call('areas', \@councils); - foreach my $problem (@problems) { - if ($problem->council) { - my @council_names = map { $areas_info->{$_}->{name} } @{$problem->council} ; - $problem->council( join(' and ', @council_names) ); + my $bodies = $problem->bodies; + if (keys %$bodies) { + my @body_names = map { $_->name } values %$bodies; + $problem->bodies_str( join(' and ', @body_names) ); } } |