diff options
author | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
commit | 09dacfc6b8bf62addeee16c20b1d90c2a256da96 (patch) | |
tree | 7caa2bf9e92227ab74448f9b746dd28bbcb81b2a /perllib/FixMyStreet/DB/ResultSet/Nearby.pm | |
parent | 585e57484f9c6332668bf1ac0a6a3b39dbe32223 (diff) | |
parent | cea89fb87a96943708a1db0f646492fbfaaf000f (diff) |
Merge tag 'v3.1' into fiksgatami-devfiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Nearby.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Nearby.pm | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm index 2ebe309e3..af1142c3a 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm @@ -17,16 +17,16 @@ sub nearby { } my $params = { - state => [ keys %{$args{states}} ], + 'problem.state' => [ keys %{$args{states}} ], }; - $params->{id} = { -not_in => $args{ids} } + $params->{problem_id} = { -not_in => $args{ids} } if $args{ids}; - $params->{category} = $args{categories} if $args{categories} && @{$args{categories}}; + $params->{'problem.category'} = $args{categories} if $args{categories} && @{$args{categories}}; $params->{$c->stash->{report_age_field}} = { '>=', \"current_timestamp-'$args{report_age}'::interval" } if $args{report_age}; - FixMyStreet::DB::ResultSet::Problem->non_public_if_possible($params, $c); + FixMyStreet::DB::ResultSet::Problem->non_public_if_possible($params, $c, 'problem'); $rs = $c->cobrand->problems_restriction($rs); @@ -34,11 +34,22 @@ sub nearby { $params = { %$params, %{$args{extra}} } if $args{extra}; my $attrs = { - prefetch => 'problem', + prefetch => { problem => [] }, bind => [ $args{latitude}, $args{longitude}, $args{distance} ], order_by => [ 'distance', { -desc => 'created' } ], rows => $args{limit}, }; + if ($c->user_exists) { + if ($c->user->from_body || $c->user->is_superuser) { + push @{$attrs->{prefetch}{problem}}, 'contact'; + } + if ($c->user->has_body_permission_to('planned_reports')) { + push @{$attrs->{prefetch}{problem}}, 'user_planned_reports'; + } + if ($c->user->has_body_permission_to('report_edit_priority') || $c->user->has_body_permission_to('report_inspect')) { + push @{$attrs->{prefetch}{problem}}, 'response_priority'; + } + } my @problems = mySociety::Locale::in_gb_locale { $rs->search( $params, $attrs )->all }; return \@problems; |