From 19ca3aa8dbc4f551836cd0dac9150118c9128ee1 Mon Sep 17 00:00:00 2001 From: "terry%netscape.com" <> Date: Wed, 24 Mar 1999 06:32:19 +0000 Subject: Can now query for a specified field being changed at a specified time, optionally to a specified value. --- buglist.cgi | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'buglist.cgi') diff --git a/buglist.cgi b/buglist.cgi index b5f5e1608..196357804 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -23,6 +23,7 @@ use diagnostics; use strict; require "CGI.pl"; +use Date::Parse; my $serverpush = 1; @@ -340,6 +341,57 @@ Click the Back button and try again."; } } +my $ref = $::MFORM{'chfield'}; + + +sub SqlifyDate { + my ($str) = (@_); + if (!defined $str) { + $str = ""; + } + my $date = str2time($str); + if (!defined $date) { + print "The string '$str' is not a legal date.\n"; + print "

Please click the Back button and try again.\n"; + exit; + } + return time2str("'%Y/%m/%d %H:%M:%S'", $date); +} + + + + + +if (defined $ref && 0 < @$ref) { + # Do surgery on the query to tell it to patch in the bugs_activity + # table. + $query =~ s/bugs,/bugs, bugs_activity,/; + + my @list; + foreach my $f (@$ref) { + push(@list, "\nbugs_activity.field = " . SqlQuote($f)); + } + $query .= "and bugs_activity.bug_id = bugs.bug_id and (" . + join(' or ', @list) . ") "; + $query .= "and bugs_activity.when >= " . + SqlifyDate($::FORM{'chfieldfrom'}) . "\n"; + my $to = $::FORM{'chfieldto'}; + if (defined $to) { + $to = trim($to); + if ($to ne "" && $to !~ /^now$/i) { + $query .= "and bugs_activity.when <= " . SqlifyDate($to) . "\n"; + } + } + my $value = $::FORM{'chfieldvalue'}; + if (defined $value) { + $value = trim($value); + if ($value ne "") { + $query .= "and bugs_activity.newvalue = " . + SqlQuote($value) . "\n"; + } + } +} + foreach my $f ("short_desc", "long_desc", "bug_file_loc", "status_whiteboard") { if (defined $::FORM{$f}) { -- cgit v1.2.3-24-g4f1b