diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-19 10:53:58 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-19 10:53:58 +0000 |
commit | ef28987bc739f3c6cf3119574cf311cfae069b2e (patch) | |
tree | b187c43bfd33fc603631998635a331a640af12df /perllib/FixMyStreet/App/Controller/Report.pm | |
parent | 19d4efadccd980750e6dcb81e163489bc3d62b85 (diff) | |
parent | 684405c7808cc71567f52cbba6d595326438b876 (diff) |
Merge branch '1939-questionnaire-links'
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index b9d773f5e..ec0e6f886 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -167,17 +167,28 @@ sub load_updates : Private { { problem_id => $c->stash->{problem}->id, whenanswered => { '!=', undef }, - old_state => 'confirmed', new_state => 'confirmed', + old_state => [ -and => + { -in => [ FixMyStreet::DB::Result::Problem::closed_states, FixMyStreet::DB::Result::Problem::open_states ] }, + \'= new_state', + ] }, { order_by => 'whenanswered' } ); my @combined; + my %questionnaires_with_updates; while (my $update = $updates->next) { push @combined, [ $update->confirmed, $update ]; + if (my $qid = $update->get_extra_metadata('questionnaire_id')) { + $questionnaires_with_updates{$qid} = $update; + } } - while (my $update = $questionnaires->next) { - push @combined, [ $update->whenanswered, $update ]; + while (my $q = $questionnaires->next) { + if (my $update = $questionnaires_with_updates{$q->id}) { + $update->set_extra_metadata('open_from_questionnaire', 1); + next; + } + push @combined, [ $q->whenanswered, $q ]; } @combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined; $c->stash->{updates} = \@combined; |