From 19282ec337a17cb4edeed7fc6eb02def285b2394 Mon Sep 17 00:00:00 2001
From: Byron Jones
Date: Tue, 28 Jan 2014 14:15:01 +0800
Subject: Bug 76498: QuickSearch: support comparison operators other than
substring
---
Bugzilla/Search/Quicksearch.pm | 20 +++++++++--
template/en/default/pages/quicksearch.html.tmpl | 46 +++++++++++++++++++++++++
2 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm
index 9c252d04f..6f0f8c939 100644
--- a/Bugzilla/Search/Quicksearch.pm
+++ b/Bugzilla/Search/Quicksearch.pm
@@ -116,6 +116,17 @@ use constant FIELD_OPERATOR => {
owner_idle_time => 'greaterthan',
};
+# Mappings for operators symbols to support operators other than "substring"
+use constant OPERATOR_SYMBOLS => {
+ ':' => 'substring',
+ '=' => 'equals',
+ '!=' => 'notequals',
+ '>=' => 'greaterthaneq',
+ '<=' => 'lessthaneq',
+ '>' => 'greaterthan',
+ '<' => 'lessthan',
+};
+
# We might want to put this into localconfig or somewhere
use constant PRODUCT_EXCEPTIONS => (
'row', # [Browser]
@@ -425,8 +436,9 @@ sub _handle_field_names {
# Generic field1,field2,field3:value1,value2 notation.
# We have to correctly ignore commas and colons in quotes.
- my @field_values = _parse_line(':', 1, $or_operand);
- if (scalar @field_values == 2) {
+ foreach my $symbol (keys %{ OPERATOR_SYMBOLS() }) {
+ my @field_values = _parse_line($symbol, 1, $or_operand);
+ next unless scalar @field_values == 2;
my @fields = _parse_line(',', 1, $field_values[0]);
my @values = _parse_line(',', 1, $field_values[1]);
foreach my $field (@fields) {
@@ -446,7 +458,9 @@ sub _handle_field_names {
}
foreach my $value (@values) {
next unless defined $value;
- my $operator = FIELD_OPERATOR->{$translated} || 'substring';
+ my $operator = FIELD_OPERATOR->{$translated}
+ || OPERATOR_SYMBOLS->{$symbol}
+ || 'substring';
# If the string was quoted to protect some special
# characters such as commas and colons, we need
# to remove quotes.
diff --git a/template/en/default/pages/quicksearch.html.tmpl b/template/en/default/pages/quicksearch.html.tmpl
index c43047d9f..18bf4dfb1 100644
--- a/template/en/default/pages/quicksearch.html.tmpl
+++ b/template/en/default/pages/quicksearch.html.tmpl
@@ -229,6 +229,52 @@
(url OR location) AND (bar OR
field) AND (NOT focus)
+
+
+ The default operator, colon (:), performs a substring
+ match of the value. The following operators are supported:
+
+ -
+ : (substring):
+ summary:foo will search for [% terms.bugs %]
+ where the summary contains foo.
+
+ -
+ = (equals):
+ summary=foo will search for [% terms.bugs %]
+ where the summary is exactly foo.
+
+ -
+ != (notequals):
+ summary!=foo will search for [% terms.bugs %]
+ where the summary is not foo.
+
+ -
+ > (greaterthan):
+ creation_ts>-2w will search for [% terms.bugs %]
+ where that were created between two weeks ago and now, excluding [%
+ terms.bugs %] exactly two weeks old.
+
+ -
+ >= (greaterthaneq):
+ creation_ts>=-2w will search for [% terms.bugs %]
+ where that were created between two weeks ago and now, including [%
+ terms.bugs %] exactly two weeks old.
+
+ -
+ < (lessthan):
+ creation_ts<-2w will search for [% terms.bugs %]
+ where that were created more than two weeks ago, excluding [%
+ terms.bugs %] exactly two weeks old.
+
+ -
+ <= (lessthaneq):
+ creation_ts<=-2w will search for [% terms.bugs %]
+ where that were created more than two weeks ago, including [%
+ terms.bugs %] exactly two weeks old.
+
+
+
Advanced Shortcuts
--
cgit v1.2.3-24-g4f1b