From 61e130783830050ac35093ad49c5fb2c75f12257 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 26 Apr 2013 09:50:29 +0100 Subject: Send email to Zurich DM when report in planned state after more than six days. --- bin/zurich-overdue-alert | 5 +++-- perllib/FixMyStreet/Cobrand/Zurich.pm | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/zurich-overdue-alert b/bin/zurich-overdue-alert index 3ba8b9163..4a507c481 100755 --- a/bin/zurich-overdue-alert +++ b/bin/zurich-overdue-alert @@ -24,14 +24,15 @@ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('zurich')->new(); my %bodies = map { $_->id => $_ } FixMyStreet::App->model("DB::Body")->all; loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed', 'confirmed' ] ); -loop_through( 'alert-overdue.txt', 1, 5, 'in progress' ); +loop_through( 'alert-overdue.txt', 1, 6, 'in progress' ); +loop_through( 'alert-overdue.txt', 0, 6, 'planned' ); sub loop_through { my ( $template, $include_parent, $days, $states ) = @_; my $reports = FixMyStreet::App->model("DB::Problem")->search( { state => $states, - whensent => { '<', FixMyStreet::Cobrand::Zurich::sub_days( $now, $days ) }, + created => { '<', FixMyStreet::Cobrand::Zurich::sub_days( $now, $days ) }, bodies_str => { '!=', undef }, } ); diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 5c873ceb5..d69fdebd2 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -168,16 +168,16 @@ sub sub_days { sub overdue { my ( $self, $problem ) = @_; - my $w = $problem->whensent; + my $w = $problem->created; return 0 unless $w; if ( $problem->state eq 'unconfirmed' || $problem->state eq 'confirmed' ) { # One working day $w = add_days( $w, 1 ); return $w < DateTime->now() ? 1 : 0; - } elsif ( $problem->state eq 'in progress' ) { - # Five working days - $w = add_days( $w, 5 ); + } elsif ( $problem->state eq 'in progress' || $problem->state eq 'planned' ) { + # Six working days from creation + $w = add_days( $w, 6 ); return $w < DateTime->now() ? 1 : 0; } else { return 0; -- cgit v1.2.3