diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-21 09:39:01 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-21 09:39:01 +0000 |
commit | 03ae1d02091262b19d87ba47cd0ea5db0404df16 (patch) | |
tree | e1f834db1effd68b87fb84e1e862fe6bc5d2067b /perllib/FixMyStreet/App/Controller/Report.pm | |
parent | eb46ce3f4155fdd9333432ecc6ad773dae79dc91 (diff) | |
parent | 5724c6adf8db7cca611fcc000e6fa4e995fcc2bd (diff) |
Merge branch '2357-show-more-questionnaire-updates'
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 10aabd1fd..58ce64af6 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -186,14 +186,30 @@ sub load_updates : Private { { order_by => [ 'confirmed', 'id' ] } ); - my $questionnaires = $c->model('DB::Questionnaire')->search( + my $questionnaires_still_open = $c->model('DB::Questionnaire')->search( { problem_id => $c->stash->{problem}->id, whenanswered => { '!=', undef }, - old_state => [ -and => - { -in => [ FixMyStreet::DB::Result::Problem::closed_states, FixMyStreet::DB::Result::Problem::open_states ] }, - \'= new_state', - ] + -or => [ { + # Any steady state open/closed + old_state => [ -and => + { -in => [ FixMyStreet::DB::Result::Problem::closed_states, FixMyStreet::DB::Result::Problem::open_states ] }, + \'= new_state', + ], + }, { + # Any reopening + new_state => 'confirmed', + } ] + }, + { order_by => 'whenanswered' } + ); + + my $questionnaires_fixed = $c->model('DB::Questionnaire')->search( + { + problem_id => $c->stash->{problem}->id, + whenanswered => { '!=', undef }, + old_state => { -not_in => [ FixMyStreet::DB::Result::Problem::fixed_states ] }, + new_state => { -in => [ FixMyStreet::DB::Result::Problem::fixed_states ] }, }, { order_by => 'whenanswered' } ); @@ -206,13 +222,17 @@ sub load_updates : Private { $questionnaires_with_updates{$qid} = $update; } } - while (my $q = $questionnaires->next) { + while (my $q = $questionnaires_still_open->next) { if (my $update = $questionnaires_with_updates{$q->id}) { $update->set_extra_metadata('open_from_questionnaire', 1); next; } push @combined, [ $q->whenanswered, $q ]; } + while (my $q = $questionnaires_fixed->next) { + next if $questionnaires_with_updates{$q->id}; + push @combined, [ $q->whenanswered, $q ]; + } @combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined; $c->stash->{updates} = \@combined; |