aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorpezholio <pezholio@gmail.com>2017-02-02 15:25:27 +0000
committerpezholio <pezholio@gmail.com>2017-02-07 09:53:21 +0000
commit81b642a59ec389399131880f4850148157787c38 (patch)
tree5357b048d5e9fdc6551e638e073441aa7d4efd66 /perllib
parent263ba94fe4ba91ef08cfada386900669ff289a2b (diff)
Add shortlist filters
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm39
1 files changed, 34 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 2635b7b7a..69a2ddb0f 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -378,6 +378,25 @@ sub load_and_group_problems : Private {
non_public => 0,
state => [ keys %$states ]
};
+ my $filter = {
+ order_by => $c->stash->{sort_order},
+ rows => $c->cobrand->reports_per_page,
+ };
+
+ if (defined $c->stash->{filter_status}{shortlisted}) {
+ $where->{'me.id'} = { '=', \"user_planned_reports.report_id"};
+ $where->{'user_planned_reports.removed'} = undef;
+ $filter->{join} = 'user_planned_reports';
+ } elsif (defined $c->stash->{filter_status}{unshortlisted}) {
+ my $shortlisted_ids = $c->cobrand->problems->search({
+ 'me.id' => { '=', \"user_planned_reports.report_id"},
+ 'user_planned_reports.removed' => undef,
+ }, {
+ join => 'user_planned_reports',
+ columns => ['me.id'],
+ })->as_query;
+ $where->{'me.id'} = { -not_in => $shortlisted_ids };
+ }
my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ];
if ( $type eq 'new' ) {
@@ -413,11 +432,9 @@ sub load_and_group_problems : Private {
$problems = $problems->search(
$where,
- {
- order_by => $c->stash->{sort_order},
- rows => $c->cobrand->reports_per_page,
- }
+ $filter
)->include_comment_counts->page( $page );
+
$c->stash->{pager} = $problems->pager;
my ( %problems, @pins );
@@ -500,6 +517,19 @@ sub stash_report_filter_status : Private {
%filter_problem_states = %$s;
}
+ if ($status{shortlisted}) {
+ $filter_status{shortlisted} = 1;
+ }
+
+ if ($status{unshortlisted}) {
+ $filter_status{unshortlisted} = 1;
+ }
+
+ if (keys %filter_problem_states == 0) {
+ my $s = FixMyStreet::DB::Result::Problem->open_states();
+ %filter_problem_states = (%filter_problem_states, %$s);
+ }
+
$c->stash->{filter_problem_states} = \%filter_problem_states;
$c->stash->{filter_status} = \%filter_status;
return 1;
@@ -577,4 +607,3 @@ Licensed under the Affero GPL.
__PACKAGE__->meta->make_immutable;
1;
-