diff options
author | Byron Jones <glob@mozilla.com> | 2015-07-13 20:00:51 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-07-13 20:00:51 +0200 |
commit | 43740a1ba3a3ee680033fbea7c23daab221016d5 (patch) | |
tree | 76f47c17315890a117c8ff702a33d70b7eb6cc5a /extensions/RequestNagger/bin | |
parent | 77f0501214e4a23415b7f4bd8b294510d8b38621 (diff) | |
download | bugzilla-43740a1ba3a3ee680033fbea7c23daab221016d5.tar.gz bugzilla-43740a1ba3a3ee680033fbea7c23daab221016d5.tar.xz |
Bug 984438 - Don't send 'Your Overdue Requests' reminder emails on weekends
Diffstat (limited to 'extensions/RequestNagger/bin')
-rwxr-xr-x | extensions/RequestNagger/bin/send-request-nags.pl | 14 |
1 files changed, 13 insertions, 1 deletions
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; } |