summaryrefslogtreecommitdiffstats
path: root/extensions/RequestNagger
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-07-13 20:00:51 +0200
committerByron Jones <glob@mozilla.com>2015-07-13 20:00:51 +0200
commit43740a1ba3a3ee680033fbea7c23daab221016d5 (patch)
tree76f47c17315890a117c8ff702a33d70b7eb6cc5a /extensions/RequestNagger
parent77f0501214e4a23415b7f4bd8b294510d8b38621 (diff)
downloadbugzilla-43740a1ba3a3ee680033fbea7c23daab221016d5.tar.gz
bugzilla-43740a1ba3a3ee680033fbea7c23daab221016d5.tar.xz
Bug 984438 - Don't send 'Your Overdue Requests' reminder emails on weekends
Diffstat (limited to 'extensions/RequestNagger')
-rwxr-xr-xextensions/RequestNagger/bin/send-request-nags.pl14
-rw-r--r--extensions/RequestNagger/lib/Constants.pm16
2 files changed, 25 insertions, 5 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;
}
diff --git a/extensions/RequestNagger/lib/Constants.pm b/extensions/RequestNagger/lib/Constants.pm
index 9f1b0ba98..435c0b167 100644
--- a/extensions/RequestNagger/lib/Constants.pm
+++ b/extensions/RequestNagger/lib/Constants.pm
@@ -62,7 +62,9 @@ sub REQUESTEE_NAG_SQL {
setter.userid AS setter_id,
requestee.userid AS requestee_id,
flags.requestee_id AS recipient_id,
- flags.requestee_id AS target_id
+ flags.requestee_id AS target_id,
+ products.nag_interval,
+ 0 AS extended_period
FROM
flags
INNER JOIN flagtypes ON flagtypes.id = flags.type_id
@@ -104,7 +106,9 @@ sub SETTER_NAG_SQL {
setter.userid AS setter_id,
requestee.userid AS requestee_id,
flags.setter_id AS recipient_id,
- flags.setter_id AS target_id
+ flags.setter_id AS target_id,
+ products.nag_interval,
+ 0 AS extended_period
FROM
flags
INNER JOIN flagtypes ON flagtypes.id = flags.type_id
@@ -147,7 +151,9 @@ sub WATCHING_REQUESTEE_NAG_SQL {
setter.userid AS setter_id,
requestee.userid AS requestee_id,
nag_watch.watcher_id AS recipient_id,
- requestee.userid AS target_id
+ requestee.userid AS target_id,
+ products.nag_interval,
+ COALESCE(extended_period.setting_value, 0) AS extended_period
FROM
flags
INNER JOIN flagtypes ON flagtypes.id = flags.type_id
@@ -197,7 +203,9 @@ sub WATCHING_SETTER_NAG_SQL {
setter.userid AS setter_id,
requestee.userid AS requestee_id,
nag_watch.watcher_id AS recipient_id,
- setter.userid AS target_id
+ setter.userid AS target_id,
+ products.nag_interval,
+ COALESCE(extended_period.setting_value, 0) AS extended_period
FROM
flags
INNER JOIN flagtypes ON flagtypes.id = flags.type_id