diff options
author | myk%mozilla.org <> | 2004-04-06 09:11:17 +0200 |
---|---|---|
committer | myk%mozilla.org <> | 2004-04-06 09:11:17 +0200 |
commit | 1c03d215b0cb81a8deb67f58c345abd2b6f5f739 (patch) | |
tree | b48f4869c6bc81b68cf75e9e3575c89d6ec133fd /Bugzilla | |
parent | 9efdf77d17bb89a4e9a82081b5412f42e63879ee (diff) | |
download | bugzilla-1c03d215b0cb81a8deb67f58c345abd2b6f5f739.tar.gz bugzilla-1c03d215b0cb81a8deb67f58c345abd2b6f5f739.tar.xz |
Fix for bug 237176: allows power users to display relevance values as a column in the search results for a fulltext search
r=justdave
a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Search.pm | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 3db341c7f..6d3c7c916 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -429,12 +429,9 @@ sub init { # The term to use in the WHERE clause. $term = $term1; - # In order to sort by relevance, we SELECT the relevance value - # and give it an alias so we can add it to the SORT BY clause - # when we build that clause in buglist.cgi. We also flag the - # query in Bugzilla with the "sorted_by_relevance" flag - # so buglist.cgi knows to sort by relevance instead of anything - # else the user selected. + # In order to sort by relevance (in case the user requests it), + # we SELECT the relevance value and give it an alias so we can + # add it to the SORT BY clause when we build it in buglist.cgi. # # Note: MySQL calculates relevance for each comment separately, # so we need to do some additional calculations to get an overall @@ -446,8 +443,19 @@ sub init { # Note: We should be calculating the average relevance of all # comments for a bug, not just matching comments, but that's hard # (see http://bugzilla.mozilla.org/show_bug.cgi?id=145588#c35). - push(@fields, "(SUM($term1)/COUNT($term1) + $term2) AS relevance"); - $self->{'sorted_by_relevance'} = 1; + my $select_term = + "(SUM($term1)/COUNT($term1) + $term2) AS relevance"; + + # Users can specify to display the relevance field, in which case + # it'll show up in the list of fields being selected, and we need + # to replace that occurrence with our select term. Otherwise + # we can just add the term to the list of fields being selected. + if (grep($_ eq "relevance", @fields)) { + @fields = map($_ eq "relevance" ? $select_term : $_ , @fields); + } + else { + push(@fields, $select_term); + } }, "^long_?desc," => sub { my $table = "longdescs_$chartid"; |