2 # -*- Mode: perl; indent-tabs-mode: nil -*-
4 # The contents of this file are subject to the Mozilla Public
5 # License Version 1.1 (the "License"); you may not use this file
6 # except in compliance with the License. You may obtain a copy of
7 # the License at http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS
10 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 # implied. See the License for the specific language governing
12 # rights and limitations under the License.
14 # The Original Code is the Bugzilla Bug Tracking System.
16 # The Initial Developer of the Original Code is Netscape Communications
17 # Corporation. Portions created by Netscape are
18 # Copyright (C) 1998 Netscape Communications Corporation. All
21 # Contributor(s): Terry Weissman <terry@mozilla.org>
22 # Joseph Heenan <joseph@heenan.me.uk>
23 # Frédéric Buclin <LpSolit@gmail.com>
26 # This is a script suitable for running once a day from a cron job. It
27 # looks at all the bugs, and sends whiny mail to anyone who has a bug
28 # assigned to them that has status NEW or REOPENED that has not been
29 # touched for more than the number of days specified in the whinedays param.
39 # Whining is disabled if whinedays is zero
40 exit unless Bugzilla
->params->{'whinedays'} >= 1;
42 my $dbh = Bugzilla
->dbh;
43 my $query = q{SELECT bug_id, short_desc, login_name
46 ON userid = assigned_to
47 WHERE (bug_status = ? OR bug_status = ?)
49 AND } . $dbh->sql_to_days('NOW()') . " - " .
50 $dbh->sql_to_days('delta_ts') . " > " .
51 Bugzilla
->params->{'whinedays'} .
57 my $slt_bugs = $dbh->selectall_arrayref($query, undef, 'NEW', 'REOPENED');
59 foreach my $bug (@
$slt_bugs) {
60 my ($id, $desc, $email) = @
$bug;
61 if (!defined $bugs{$email}) {
64 if (!defined $desc{$email}) {
67 push @
{$bugs{$email}}, $id;
68 push @
{$desc{$email}}, $desc;
72 foreach my $email (sort (keys %bugs)) {
73 my $user = new Bugzilla
::User
({name
=> $email});
74 next if $user->email_disabled;
76 my $vars = {'email' => $email};
79 foreach my $i (@
{$bugs{$email}}) {
81 $bug->{'summary'} = shift(@
{$desc{$email}});
85 $vars->{'bugs'} = \
@bugs;
88 my $template = Bugzilla
->template_inner($user->settings->{'lang'}->{'value'});
89 $template->process("email/whine.txt.tmpl", $vars, \
$msg)
90 or die($template->error());
92 Bugzilla
->template_inner("");
95 print "$email " . join(" ", @
{$bugs{$email}}) . "\n";