From ab7a5316bd6a65b2e3fb38ce2fe506e259045555 Mon Sep 17 00:00:00 2001 From: "bbaetz%student.usyd.edu.au" Date: Sun, 3 Mar 2002 22:06:20 +0000 Subject: [PATCH] Bug 106377 - processmail rescanall should use lastdiffed r=justdave, ddkilzer@theracingworld.com --- webtools/bugzilla/editcomponents.cgi | 3 ++- webtools/bugzilla/editgroups.cgi | 2 +- webtools/bugzilla/editmilestones.cgi | 3 ++- webtools/bugzilla/editproducts.cgi | 2 +- webtools/bugzilla/editversions.cgi | 3 ++- webtools/bugzilla/processmail | 16 +++++++++++++--- webtools/bugzilla/sanitycheck.cgi | 24 ++++++++++++++++++++++++ 7 files changed, 45 insertions(+), 8 deletions(-) diff --git a/webtools/bugzilla/editcomponents.cgi b/webtools/bugzilla/editcomponents.cgi index 4d4079626d99..310ce5f01960 100755 --- a/webtools/bugzilla/editcomponents.cgi +++ b/webtools/bugzilla/editcomponents.cgi @@ -787,7 +787,8 @@ if ($action eq 'update') { } SendSQL("UPDATE bugs - SET component=" . SqlQuote($component) . " + SET component=" . SqlQuote($component) . ", + delta_ts = delta_ts WHERE component=" . SqlQuote($componentold) . " AND product=" . SqlQuote($product)); SendSQL("UPDATE components diff --git a/webtools/bugzilla/editgroups.cgi b/webtools/bugzilla/editgroups.cgi index dfcca8a3f56e..62bb4b501e7e 100755 --- a/webtools/bugzilla/editgroups.cgi +++ b/webtools/bugzilla/editgroups.cgi @@ -518,7 +518,7 @@ if ($action eq 'delete') { } SendSQL("SELECT bug_id FROM bugs WHERE (groupset & $bit)"); if (FetchOneColumn()) { - SendSQL("UPDATE bugs SET groupset=(groupset-$bit) " . + SendSQL("UPDATE bugs SET groupset=(groupset-$bit), delta_ts=delta_ts " . "WHERE (groupset & $bit)"); print "All bugs have had group bit $bit cleared. Any of these " . "bugs that were not also in another group are now " . diff --git a/webtools/bugzilla/editmilestones.cgi b/webtools/bugzilla/editmilestones.cgi index 0bd1dac142f9..b7ec7316f4f8 100755 --- a/webtools/bugzilla/editmilestones.cgi +++ b/webtools/bugzilla/editmilestones.cgi @@ -530,7 +530,8 @@ if ($action eq 'update') { exit; } SendSQL("UPDATE bugs - SET target_milestone=" . SqlQuote($milestone) . " + SET target_milestone=" . SqlQuote($milestone) . ", + delta_ts=delta_ts WHERE target_milestone=" . SqlQuote($milestoneold) . " AND product=" . SqlQuote($product)); SendSQL("UPDATE milestones diff --git a/webtools/bugzilla/editproducts.cgi b/webtools/bugzilla/editproducts.cgi index 536102f81729..c11c65db712f 100755 --- a/webtools/bugzilla/editproducts.cgi +++ b/webtools/bugzilla/editproducts.cgi @@ -1004,7 +1004,7 @@ if ($action eq 'update') { exit; } - SendSQL("UPDATE bugs SET product=$qp WHERE product=$qpold"); + SendSQL("UPDATE bugs SET product=$qp, delta_ts=delta_ts WHERE product=$qpold"); SendSQL("UPDATE components SET program=$qp WHERE program=$qpold"); SendSQL("UPDATE products SET product=$qp WHERE product=$qpold"); SendSQL("UPDATE versions SET program=$qp WHERE program=$qpold"); diff --git a/webtools/bugzilla/editversions.cgi b/webtools/bugzilla/editversions.cgi index 8c5e71c43dc9..19ec338c32dc 100755 --- a/webtools/bugzilla/editversions.cgi +++ b/webtools/bugzilla/editversions.cgi @@ -529,7 +529,8 @@ if ($action eq 'update') { exit; } SendSQL("UPDATE bugs - SET version=" . SqlQuote($version) . " + SET version=" . SqlQuote($version) . ", + delta_ts = delta_ts WHERE version=" . SqlQuote($versionold) . " AND product=" . SqlQuote($product)); SendSQL("UPDATE versions diff --git a/webtools/bugzilla/processmail b/webtools/bugzilla/processmail index 2bea93da639c..b5f85e695773 100755 --- a/webtools/bugzilla/processmail +++ b/webtools/bugzilla/processmail @@ -831,15 +831,25 @@ if ($#ARGV == 1) { } if ($ARGV[0] eq "rescanall") { - print "
Collecting bug ids...\n"; - SendSQL("select bug_id from bugs where to_days(now()) - to_days(delta_ts) <= 2 order by bug_id"); + print "Collecting bug ids...\n"; + SendSQL("select bug_id, lastdiffed, delta_ts from bugs where lastdiffed < delta_ts AND delta_ts < date_sub(now(), INTERVAL 30 minute) order by bug_id"); my @list; while (my @row = FetchSQLData()) { + my $time = $row[2]; + if ($time =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { + $time = "$1-$2-$3 $4:$5:$6"; + } + print STDERR "Bug $row[0] has unsent mail. lastdiffed is $row[1], delta_ts is $time.\n"; push @list, $row[0]; } + if (scalar(@list) > 0) { + print STDERR scalar(@list) . " bugs found with possibly unsent mail\n"; + print STDERR "Updating bugs, sending mail if required\n"; + } else { + print "All appropriate mail appears to have been sent\n" + } foreach my $id (@list) { if (detaint_natural($id)) { - print "
Doing bug $id\n"; ProcessOneBug($id); } } diff --git a/webtools/bugzilla/sanitycheck.cgi b/webtools/bugzilla/sanitycheck.cgi index c85a3668e879..902557bb8ae3 100755 --- a/webtools/bugzilla/sanitycheck.cgi +++ b/webtools/bugzilla/sanitycheck.cgi @@ -582,6 +582,30 @@ if (@badbugs > 0) { join (", ", @badbugs)); } +########################################################################### +# Unsent mail +########################################################################### + +Status("Checking for unsent mail"); + +@badbugs = (); + +SendSQL("SELECT bug_id " . + "FROM bugs WHERE lastdiffed < delta_ts AND ". + "delta_ts < date_sub(now(), INTERVAL 30 minute) ". + "ORDER BY bug_id"); + +while (@row = FetchSQLData()) { + my ($id) = (@row); + push(@badbugs, $id); +} + +if (@badbugs > 0) { + Alert("Bugs that have changes but no mail sent for at least half an hour: " . + join (", ", @badbugs)); + print("Run processmail rescanall to fix this

\n"); +} + ########################################################################### # End ###########################################################################