summaryrefslogtreecommitdiffstats
path: root/extensions/ProdCompSearch/lib/WebService.pm
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/ProdCompSearch/lib/WebService.pm')
-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;