From 43740a1ba3a3ee680033fbea7c23daab221016d5 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 14 Jul 2015 02:00:51 +0800 Subject: Bug 984438 - Don't send 'Your Overdue Requests' reminder emails on weekends --- extensions/RequestNagger/bin/send-request-nags.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'extensions/RequestNagger/bin') diff --git a/extensions/RequestNagger/bin/send-request-nags.pl b/extensions/RequestNagger/bin/send-request-nags.pl index 885a82ff1..03ff8b4ea 100755 --- a/extensions/RequestNagger/bin/send-request-nags.pl +++ b/extensions/RequestNagger/bin/send-request-nags.pl @@ -26,7 +26,7 @@ use Bugzilla::Extension::RequestNagger::Bug; use Bugzilla::Extension::RequestNagger::Settings; use Bugzilla::Mailer; use Bugzilla::User; -use Bugzilla::Util qw(format_time); +use Bugzilla::Util qw(format_time datetime_from); use Email::MIME; use File::Slurp qw(read_file); use File::Temp qw(tempfile); @@ -45,6 +45,7 @@ if (my $filename = shift @ARGV) { my $dbh = Bugzilla->dbh; my $date = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); +my $now = datetime_from($date)->truncate( to => 'day' ); $date = format_time($date, '%a, %d %b %Y %T %z', 'UTC'); # delete expired defers @@ -179,6 +180,17 @@ sub _include_request { return 0 if $attachment->isprivate && !$recipient->is_insider; } + # exclude weekends and re-check nag-interval + my $date = datetime_from($request->{modification_date}); + my $hours = 0; + $hours += 24 - $date->hour if $date->day_of_week <= 5; + $date->add( days => 1 )->truncate( to => 'day' ); + while ($date < $now) { + $hours += 24 if $date->day_of_week <= 5; + $date->add( days => 1 ); + } + return 0 if $hours < ($request->{extended_period} ? $request->{nag_interval} + 24 : $request->{nag_interval}); + return 1; } -- cgit v1.2.3-24-g4f1b