summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-05-15 06:12:10 +0200
committerByron Jones <glob@mozilla.com>2015-05-15 06:12:10 +0200
commitd1419f874824dd5a0a4d4499d13a0941ee434044 (patch)
tree201427af8dc43e27ca9eb26199481613db56c6bb /extensions
parent014dc8595070533eb7a14771e98640f74037ff78 (diff)
downloadbugzilla-d1419f874824dd5a0a4d4499d13a0941ee434044.tar.gz
bugzilla-d1419f874824dd5a0a4d4499d13a0941ee434044.tar.xz
Bug 908387: product/component searching should sort hits on product/component name before hits on descriptions
Diffstat (limited to 'extensions')
-rw-r--r--extensions/ProdCompSearch/lib/WebService.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/extensions/ProdCompSearch/lib/WebService.pm b/extensions/ProdCompSearch/lib/WebService.pm
index 3bf0e1377..a28b5d059 100644
--- a/extensions/ProdCompSearch/lib/WebService.pm
+++ b/extensions/ProdCompSearch/lib/WebService.pm
@@ -92,12 +92,14 @@ sub prod_comp_search {
push @terms, _build_terms($component, 0, 1);
push @order, "products.name != " . $dbh->quote($product) if $product ne '';
push @order, "components.name != " . $dbh->quote($component) if $component ne '';
+ push @order, _build_like_order($product . ' ' . $component);
push @order, "products.name";
push @order, "components.name";
} else {
push @terms, _build_terms($search, 1, 1);
push @order, "products.name != " . $dbh->quote($search);
push @order, "components.name != " . $dbh->quote($search);
+ push @order, _build_like_order($search);
push @order, "products.name";
push @order, "components.name";
}
@@ -147,4 +149,17 @@ sub _build_terms {
return @terms;
}
+sub _build_like_order {
+ my ($query) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ my @terms;
+ foreach my $word (split(/[\s,]+/, $query)) {
+ push @terms, "CONCAT(products.name, components.name) LIKE " . $dbh->quote('%' . $word . '%')
+ if $word ne '';
+ }
+
+ return 'NOT(' . join(' AND ', @terms) . ')';
+}
+
1;