diff options
author | Steven Day <steve@mysociety.org> | 2015-06-29 12:03:17 +0100 |
---|---|---|
committer | Steven Day <steve@mysociety.org> | 2015-06-29 15:48:10 +0100 |
commit | 69ed1cda6a315a46e3309dcf3035ad7229931829 (patch) | |
tree | a488a1f4c9485e38b40427f8edc6cce6aee5ca10 /perllib | |
parent | cb97d3247c286e3142ea6cc883fa7db187fcfb79 (diff) |
Rename map filtering GET param, remove unnecessary query
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 17 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 2 |
4 files changed, 9 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 7d382c228..c4040af95 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -240,7 +240,7 @@ sub check_location_is_acceptable : Private { =head2 check_and_stash_category -Check that the 'category' query param is valid, if it's present. Stores +Check that the 'filter_category' query param is valid, if it's present. Stores the validated string in the stash as filter_category. Puts all the valid categories in filter_categories on the stash. @@ -270,17 +270,10 @@ sub check_and_stash_category : Private { $c->stash->{filter_categories} = \@categories; - my $category = $c->req->param('category'); - if ( $category ) { - my $count = $c->model('DB::Contact')->not_deleted->search( - { - body_id => [ keys %bodies ], - category => $category - } - )->count; - if ( $count ) { - $c->stash->{filter_category} = $category; - } + my $category = $c->req->param('filter_category'); + my %categories_mapped = map { $_ => 1 } @categories; + if ( defined $category && $categories_mapped{$category} ) { + $c->stash->{filter_category} = $category; } } diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 0cea3735a..0bcee7ac6 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -54,7 +54,7 @@ sub my : Path : Args(0) { %$params } if $c->cobrand->problems_clause; - my $category = $c->req->param('category'); + my $category = $c->req->param('filter_category'); if ( $category ) { $params->{category} = $category; $c->stash->{filter_category} = $category; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 82418fc48..e5f9d9507 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -137,7 +137,7 @@ sub ward : Path : Args(2) { } )->all; @categories = map { $_->category } @categories; $c->stash->{filter_categories} = \@categories; - $c->stash->{filter_category} = $c->req->param('category'); + $c->stash->{filter_category} = $c->req->param('filter_category'); my $pins = $c->stash->{pins}; @@ -394,7 +394,7 @@ sub load_and_group_problems : Private { my $page = $c->req->params->{p} || 1; my $type = $c->req->params->{t} || 'all'; - my $category = $c->req->params->{c} || $c->req->params->{category} || ''; + my $category = $c->req->params->{c} || $c->req->params->{filter_category} || ''; # Unlike the 't' query param, 'status' isn't affected by # the age of a report, so treat the filtering separately. diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 7a9c8fa18..704b19bee 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -117,7 +117,7 @@ sub map_pins { my $bbox = $c->req->param('bbox'); my ( $min_lon, $min_lat, $max_lon, $max_lat ) = split /,/, $bbox; - my $category = $c->req->param('category'); + my $category = $c->req->param('filter_category'); # Filter reports by status, if present in query params my $states; |