aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-12-20 09:43:38 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-12-20 14:24:51 +0000
commit5724c6adf8db7cca611fcc000e6fa4e995fcc2bd (patch)
tree5d2dfe04d5606d07413e113af9f2ea0ddbac9d6f /perllib
parent649692298b0b870b161a3f8b755f46b16b534e48 (diff)
Show all questionnaire responses lacking updates.
Since questionnaire responses were recorded on email link click, we should have been showing those that reopened or fixed reports, not just steady-state "Still open" ones.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm32
-rw-r--r--perllib/FixMyStreet/DB/Result/Questionnaire.pm7
2 files changed, 33 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;
diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
index 30f2ab7ce..6b7ab9452 100644
--- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
@@ -57,4 +57,11 @@ my $stz = sub {
around whensent => $stz;
around whenanswered => $stz;
+sub marks_fixed {
+ my $self = shift;
+ my $new_fixed = FixMyStreet::DB::Result::Problem->fixed_states()->{$self->new_state};
+ my $old_fixed = FixMyStreet::DB::Result::Problem->fixed_states()->{$self->old_state};
+ return $new_fixed && !$old_fixed;
+}
+
1;