whineatnews.pl 2.34 KB
Newer Older
1
#!/usr/bin/perl -w
2 3
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
4 5 6 7 8 9 10 11 12 13
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
14
# The Original Code is the Bugzilla Bug Tracking System.
15
#
16
# The Initial Developer of the Original Code is Netscape Communications
17 18 19 20
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
21
# Contributor(s): Terry Weissman <terry@mozilla.org>
22
#                 Joseph Heenan <joseph@heenan.me.uk>
23 24 25 26


# This is a script suitable for running once a day from a cron job.  It 
# looks at all the bugs, and sends whiny mail to anyone who has a bug 
27
# assigned to them that has status NEW or REOPENED that has not been 
28
# touched for more than the number of days specified in the whinedays param.
29 30 31 32 33

use strict;

require "globals.pl";

34 35
use Bugzilla::BugMail;

36
SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " .
37 38
        "(bug_status = 'NEW' or bug_status = 'REOPENED') and " . 
        "to_days(now()) - to_days(delta_ts) > " . Param('whinedays') .
39
        " and userid=assigned_to order by bug_id");
40 41

my %bugs;
42
my %desc;
43 44 45
my @row;

while (@row = FetchSQLData()) {
46
    my ($id, $desc, $email) = (@row);
47 48 49
    if (!defined $bugs{$email}) {
        $bugs{$email} = [];
    }
50 51 52
    if (!defined $desc{$email}) {
        $desc{$email} = [];
    }
53
    push @{$bugs{$email}}, $id;
54
    push @{$desc{$email}}, $desc;
55 56 57 58 59
}


my $template = Param('whinemail');
my $urlbase = Param('urlbase');
60
my $emailsuffix = Param('emailsuffix');
61 62 63

foreach my $email (sort (keys %bugs)) {
    my %substs;
64
    $substs{'email'} = $email . $emailsuffix;
65
    $substs{'userid'} = $email;
66 67 68
    my $msg = PerformSubsts($template, \%substs);

    foreach my $i (@{$bugs{$email}}) {
69 70
        $msg .= "  " . shift(@{$desc{$email}}) . "\n";
        $msg .= "    -> ${urlbase}show_bug.cgi?id=$i\n";
71
    }
72

73 74
    Bugzilla::BugMail::MessageToMTA($msg);

75 76
    print "$email      " . join(" ", @{$bugs{$email}}) . "\n";
}