SimpleSearchIncludeResolved

From Request Tracker Wiki
Jump to navigation Jump to search

Problem

The 3.8 Series automagically limits searches to active tickets. Despite SimpleSearchExcludeResolved, some people became used to having the ability to easily search tickets of any status.

Solution 1: Robust behavior (search active, closed, or any)

This implements search keywords:

  • any to search all tickets, not just open tickets (RT3.6 behavior)
  • closed to search closed tickets

Not specifying a keyword retains the RT3.8 behavior of only searching open tickets.

Use the following callback /opt/rt3/local/html/Callbacks/stuff/Search/Simple.html/ModifyQuery to add keywords any and closed to complement the implicit active:

<%init>
   #active is the default: open new stalled
   $$query =~ s/\bany\b/new open resolved stalled rejected deleted/i;
   $$query =~ s/\bclosed\b/resolved rejected deleted/i;
   </%init>
   
   <%args>
   $query => undef
   </%args>
   
   
$$query only contains what is typed in the search box so there is no ticket status to replace in $$query. -- Bryan McLellan
I think you misunderstand the process. This isn't replacing any statuses, it's replacing custom keywords/operators with a list of statuses. This prevents RT from adding its implicit list of active statuses since the query it sees already has a list of statuses. you can acheive the same result as searching for "quux closed" with this customization as by searching for "quux resolved rejected deleted"... this just makes it easier to type. --Jerrad

Solution 2: 3.6 Behavior (results regardless of status)

This solution makes simple searches include all tickets, and breaks the ability to limit searches to tickets of a particular status by giving a status code as a search keyword.

Place the following in /opt/rt3/local/html/Callbacks/stuff/Search/Simple.html/ModifyQuery:

<%init>
$$query = $$query . " new open resolved stalled rejected deleted";
</%init>

<%args>
$query => undef
</%args>

Solution 3: 3.6 Behavior (all tickets by default)

This solution makes simple searches include all tickets by default, but retains the ability to limit searches to tickets of a particular status.

E.g. searching for "money" will search among open and resolved tickets, but searching for "money resolved" will only select resolved tickets.

I am offering this solution as a patch to the source code (apply the patch to the RT source tree, then run make upgrade).

diff --git a/lib/RT/Search/Googleish.pm b/lib/RT/Search/Googleish.pm
index b3717c1..4322259 100644
--- a/lib/RT/Search/Googleish.pm
+++ b/lib/RT/Search/Googleish.pm
@@ -176,7 +176,6 @@ sub QueryToSQL {
     push @tql_clauses, join( " OR ", sort @id_clauses );
     push @tql_clauses, join( " OR ", sort @owner_clauses );
     if ( ! @status_clauses ) {
-        push @tql_clauses, join( " OR ", map "Status = '$_'", RT::Queue->ActiveStatusArray());
     } else {
         push @tql_clauses, join( " OR ", sort @status_clauses );
     }

Solution 4: 3.6 Behavior (all tickets by default) (For RT 4)

Solution #3 cannot be applied to RT 4.x. Instead, you can add this line to RT_SiteConfig.pm:

Set($OnlySearchActiveTicketsInSimpleSearch, 0);

See RT_Config.pm for more details.