aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Council.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-10 14:40:30 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-10 14:40:30 +0100
commit40f13d3cc9dc903da5299901623677c205eff484 (patch)
treedc9ba86101496ef80ba9068cae83d7892e467dac /perllib/FixMyStreet/App/Controller/Council.pm
parentb02e8e5e29aa1b7087b08d6d7eddccae516b171a (diff)
Consolidate MaPit calls to call out to it less.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Council.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Council.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 53f7e38d8..35e3d0d11 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -48,10 +48,23 @@ sub load_and_check_councils : Private {
@area_types = $c->cobrand->area_types();
}
- # TODO: I think we want in_gb_locale around the next line, needs testing
- my $all_councils =
- mySociety::MaPit::call( 'point', "4326/$longitude,$latitude",
- type => \@area_types );
+ # TODO: I think we want in_gb_locale around the MaPit line, needs testing
+ my $all_councils;
+ if ( $c->stash->{fetch_all_areas} ) {
+ my %area_types = map { $_ => 1 } @area_types;
+ my $all_areas =
+ mySociety::MaPit::call( 'point', "4326/$longitude,$latitude" );
+ $c->stash->{all_areas} = $all_areas;
+ $all_councils = {
+ map { $_ => $all_areas->{$_} }
+ grep { $area_types{ $all_areas->{$_}->{type} } }
+ keys %$all_areas
+ };
+ } else {
+ $all_councils =
+ mySociety::MaPit::call( 'point', "4326/$longitude,$latitude",
+ type => \@area_types );
+ }
# Let cobrand do a check
my ( $success, $error_msg ) =