[Rt-commit] rt branch, 4.4/get-referenced-queues-more-search-items, created. rt-4.4.2-135-gabdee42ddb

? sunnavy sunnavy at bestpractical.com
Thu Jun 25 18:09:59 EDT 2020


The branch, 4.4/get-referenced-queues-more-search-items has been created
        at  abdee42ddb7073389115120c3a159f62acf42dc1 (commit)

- Log -----------------------------------------------------------------
commit d5b13d1364f8171f5b54d88de66034d247bca230
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 10 23:01:52 2018 +0800

    Add support of "Lifecycle =" and "Queue LIKE" to GetReferencedQueues
    
    So queue-level custom fields could show up on pages like query builder
    for queries like "Lifecycle = 'default'" or "Queue LIKE 'General'".

diff --git a/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
index d63a16d4bf..7a8d1399c0 100644
--- a/lib/RT/Interface/Web/QueryBuilder/Tree.pm
+++ b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
@@ -99,6 +99,10 @@ will appear as a key whose value is 1.
 
 sub GetReferencedQueues {
     my $self = shift;
+    my %args = (
+        CurrentUser => '',
+        @_
+    );
 
     my $queues = {};
 
@@ -110,10 +114,30 @@ sub GetReferencedQueues {
             return unless $node->isLeaf;
 
             my $clause = $node->getNodeValue();
-            return unless $clause->{Key} eq 'Queue';
-            return unless $clause->{Op} eq '=';
-
-            $queues->{ $clause->{Value} } = 1;
+            if ( $clause->{Key} eq 'Queue' ) {
+                if ( $clause->{Op} eq '=' ) {
+                    $queues->{ $clause->{Value} } ||= 1;
+                }
+                elsif ( $clause->{Op} =~ /^LIKE$/i ) {
+                    my $qs = RT::Queues->new( $args{CurrentUser} || $HTML::Mason::Commands::session{CurrentUser} );
+                    $qs->Limit( FIELD => 'Name', VALUE => $clause->{Value}, OPERATOR => 'LIKE' );
+                    while ( my $q = $qs->Next ) {
+                        next unless $q->id;
+                        $queues->{ $q->id } ||= 1;
+                    }
+                }
+            }
+            elsif ( $clause->{Key} eq 'Lifecycle' ) {
+                if ( $clause->{Op} eq '=' ) {
+                    my $qs = RT::Queues->new( $args{CurrentUser} || $HTML::Mason::Commands::session{CurrentUser} );
+                    $qs->Limit( FIELD => 'Lifecycle', VALUE => $clause->{Value} );
+                    while ( my $q = $qs->Next ) {
+                        next unless $q->id;
+                        $queues->{ $q->id } ||= 1;
+                    }
+                }
+            }
+            return;
         }
     );
 
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index fdd889044b..0c2b0f2474 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -160,7 +160,7 @@ our %GROUPINGS_META = (
                 require RT::Interface::Web::QueryBuilder::Tree;
                 my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
                 $tree->ParseSQL( Query => $args->{'Query'}, CurrentUser => $self->CurrentUser );
-                $queues = $args->{'Queues'} = $tree->GetReferencedQueues;
+                $queues = $args->{'Queues'} = $tree->GetReferencedQueues( CurrentUser => $self->CurrentUser );
             }
             return () unless $queues;
 

commit 32ee7dfc8e5ef973bb0d61aaea77d4d34a70fc03
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Jun 25 13:41:22 2020 -0400

    Document new queue and lifecycle search options

diff --git a/docs/query_builder.pod b/docs/query_builder.pod
index da08d93be3..43c9833e35 100644
--- a/docs/query_builder.pod
+++ b/docs/query_builder.pod
@@ -147,5 +147,23 @@ And there are the basics of the query builder! To implement these basics to
 build reports, please see the Dashboard & Reports document. For definitions of
 piece of RT metadata, please see the Definitions of Ticket Metadata document.
 
+=head1 Searching Custom Fields
+
+If you use custom fields on your tickets, you might initially load the Query
+Builder and not see them listed. If your custom fields are applied to
+individual queues and not globally, they won't show up as options on a
+new search. However, once you add a queue to your search, as shown above, the
+custom fields applied to the queue or queues in your search will be displayed.
+You can then add custom field values to your search just like other fields.
+
+In addition to exact queue name searches like "Queue = 'RT'", the query builder
+also allows 'LIKE' searches. This can be useful if you have several queues that
+follow some naming pattern, like "IT Support", "Printer Support", and "Email Support".
+To include all of these, you can use "Queue LIKE 'Support'".
+
+Using the Advanced tab, you can also type one other criteria to search for queues
+by their lifecycle. TicketSQL supports "Lifecycle = 'support'" if you type it
+directly into the Advanced search box.
+
 =cut
 

commit abdee42ddb7073389115120c3a159f62acf42dc1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Jun 25 13:47:21 2020 -0400

    Apply a few small changes from updated RT 5 docs

diff --git a/docs/query_builder.pod b/docs/query_builder.pod
index 43c9833e35..d5aaacc3cd 100644
--- a/docs/query_builder.pod
+++ b/docs/query_builder.pod
@@ -8,11 +8,7 @@ to find exactly what you're looking for (and no more) are discussed below.
 The Query Builder is the heart of reporting in RT, which is covered in the
 L<Dashboard and Reports|docs/dashboards_reporting.pod> document.
 
-To follow along with the examples, go to
-L<issues.bestpractical.com|http://issues.bestpractical.com> and try the
-searches yourself.
-
-=head1 Example
+=head1 Basic Ticket Searches
 
 Let's look for tickets in the "RT" queue (RT's bugtracker for itself) that have
 been resolved in the last year. (These examples assume it's currently mid June,
@@ -143,10 +139,6 @@ The same pieces of information are now spread across the display next to one
 another, which can be harder to read. So when you tell RT to display a lot of
 columns, it's usually worth adding a well-placed NEWLINE.
 
-And there are the basics of the query builder! To implement these basics to
-build reports, please see the Dashboard & Reports document. For definitions of
-piece of RT metadata, please see the Definitions of Ticket Metadata document.
-
 =head1 Searching Custom Fields
 
 If you use custom fields on your tickets, you might initially load the Query
@@ -167,3 +159,10 @@ directly into the Advanced search box.
 
 =cut
 
+=head1 Learn More
+
+To use the query builder to build and save reports, see
+L<Dashboard and Reports|docs/dashboards_reporting.pod>. For definitions of
+RT metadata, see L<Ticket Metadata|docs/ticket_metadata.pod>.
+
+=cut

-----------------------------------------------------------------------


More information about the rt-commit mailing list