]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Can now query for a specified field being changed at a specified time,
authorterry%netscape.com <>
Wed, 24 Mar 1999 06:32:19 +0000 (06:32 +0000)
committerterry%netscape.com <>
Wed, 24 Mar 1999 06:32:19 +0000 (06:32 +0000)
optionally to a specified value.

CHANGES
buglist.cgi
globals.pl
makeactivitytable.sh
query.cgi

diff --git a/CHANGES b/CHANGES
index d152a9ba1db5b21fde2bc191e2bf82d3af30b51b..7128e0ebb26a07dfee7f983a6248589d1d7cb414 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,11 @@ query the CVS tree.  For example,
 will tell you what has been changed in the last week.
 
 
+3/22/99 Added the ability to query by fields which have changed within a date
+range.  To make this perform a bit better, we need a new index:
+
+       alter table bugs_activity add index (field);
+
 3/10/99 Added 'groups' stuff, where we have different group bits that we can
 put on a person or on a bug.  Some of the group bits control access to bugzilla
 features.  And a person can't access a bug unless he has every group bit set
index b5f5e1608dfbcf3facb218f4133bf0a67fb7f984..196357804572b9cfbf41b473635863705704037c 100755 (executable)
@@ -23,6 +23,7 @@ use diagnostics;
 use strict;
 
 require "CGI.pl";
+use Date::Parse;
 
 my $serverpush = 1;
 
@@ -340,6 +341,57 @@ Click the <B>Back</B> 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 '<tt>$str</tt>' is not a legal date.\n";
+        print "<P>Please click the <B>Back</B> 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}) {
index 409d12b63a28b27f61a10e496a4f85cfd65abb7a..d6e18d225291d591cf639c76a0a96465ae415460 100644 (file)
@@ -260,6 +260,7 @@ sub GenerateVersionTable {
             splice(@::log_columns, $w, 1);
         }
     }
+    @::log_columns = (sort(@::log_columns));
 
     @::legal_priority = SplitEnumType($cols->{"priority,type"});
     @::legal_severity = SplitEnumType($cols->{"bug_severity,type"});
index 047d81e7e3eabba101535c2fd6841c3eab1d7d50..9af62ef611a928c7e36cd89c566eb82c7bb037a8 100755 (executable)
@@ -24,7 +24,6 @@ use bugs;
 
 drop table bugs_activity
 OK_ALL_DONE
-
 mysql << OK_ALL_DONE
 use bugs;
 create table bugs_activity (
@@ -36,7 +35,8 @@ create table bugs_activity (
         newvalue tinytext,
 
         index (bug_id),
-        index (when)
+        index (when),
+       index (field)
 );
 
 
index 88a690534ef5f27ce03cb38838db06cdebda6c89..08ac3f2245900e795fb52a462adcc2bce3bbc683 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -31,13 +31,13 @@ use vars @::legal_resolution,
   @::legal_product,
   @::legal_bug_status,
   @::legal_priority,
-  @::legal_resolution,
   @::legal_opsys,
   @::legal_platform,
   @::legal_components,
   @::legal_versions,
   @::legal_severity,
   @::legal_target_milestone,
+  @::log_columns,
   %::versions,
   %::components,
   %::FORM;
@@ -62,7 +62,8 @@ my %type;
 
 foreach my $name ("bug_status", "resolution", "assigned_to", "rep_platform",
                   "priority", "bug_severity", "product", "reporter", "op_sys",
-                  "component", "version",
+                  "component", "version", "chfield", "chfieldfrom",
+                  "chfieldto", "chfieldvalue",
                   "email1", "emailtype1", "emailreporter1",
                   "emailassigned_to1", "emailcc1", "emailqa_contact1",
                   "email2", "emailtype2", "emailreporter2",
@@ -92,6 +93,11 @@ foreach my $item (split(/\&/, $::buffer)) {
 }
                   
 
+if ($default{'chfieldto'} eq "") {
+    $default{'chfieldto'} = "Now";
+}
+
+
 
 my $namelist = "";
 
@@ -375,8 +381,26 @@ $emailinput2<p>
 
 
 
+Changed in the <NOBR>last <INPUT NAME=changedin SIZE=2 VALUE=\"$default{'changedin'}\"> days.</NOBR>
 
-<NOBR>Changed in the last <INPUT NAME=changedin SIZE=2> days.</NOBR>
+<table>
+<tr>
+<td rowspan=2 align=right>Where the field(s)
+</td><td rowspan=2>
+<SELECT NAME=\"chfield\" MULTIPLE SIZE=4>
+@{[make_options(\@::log_columns, $default{'chfield'}, $type{'chfield'})]}
+</SELECT>
+</td><td rowspan=2>
+changed.
+</td><td>
+<nobr>dates <INPUT NAME=chfieldfrom SIZE=10 VALUE=\"$default{'chfieldfrom'}\"></nobr>
+<nobr>to <INPUT NAME=chfieldto SIZE=10 VALUE=\"$default{'chfieldto'}\"></nobr>
+</td>
+</tr>
+<tr>
+<td>changed to value <nobr><INPUT NAME=chfieldvalue SIZE=10> (optional)</nobr>
+</td>
+</table>
 
 
 <P>