[Rt-commit] rt branch, 5.0/queue-list-limit-status-by-argument, created. rt-5.0.1-333-gddcd8425af

? sunnavy sunnavy at bestpractical.com
Tue May 11 12:26:36 EDT 2021


The branch, 5.0/queue-list-limit-status-by-argument has been created
        at  ddcd8425af95d3c5e5311a795ebd89badb82d6c6 (commit)

- Log -----------------------------------------------------------------
commit ddcd8425af95d3c5e5311a795ebd89badb82d6c6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 11 23:45:04 2021 +0800

    Limit query to active/inactive tickets in QueueList based on passed in @Statuses
    
    In 8ef6b457cb, we added QueueListAllStatuses to list all statuses, in
    which case "Status = '__Active__'" is not correct. Here we check passed
    in @Statuses to determine the status query correspondingly, i.e.
    
        * Don't limit status if it's listing all statuses
        * Limit status to active if it's listing active statuses only
        * Limit status to inactive if it's listing inactive statuses only

diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 129e2c1f52..2ed189aad3 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -91,12 +91,25 @@ my $build_search_link = sub {
 
     return RT->Config->Get('WebPath')
          . "/Search/Results.html?Query="
-         . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u');
+         . $m->interp->apply_escapes("Queue = '$queue_name' " . ( $extra_query ? "AND $extra_query" : '' ), 'u');
 };
 
+my $has_active   = grep { $_ eq 'active' } @Statuses;
+my $has_inactive = grep { $_ eq 'inactive' } @Statuses;
+my $all_query;
+if ( $has_active && $has_inactive ) {
+    $all_query = '';
+}
+elsif ($has_active) {
+    $all_query = "Status = '__Active__'";
+}
+elsif ($has_inactive) {
+    $all_query = "Status = '__Inactive__'";
+}
+
 my $link_all = sub {
     my ($queue) = @_;
-    return $build_search_link->($queue->{Name}, "Status = '__Active__'");
+    return $build_search_link->($queue->{Name}, $all_query);
 };
 
 my $link_status = sub {
@@ -135,7 +148,7 @@ my $statuses = {};
 use RT::Report::Tickets;
 my $report = RT::Report::Tickets->new( RT->SystemUser );
 my $query =
-    "(Status = '__Active__') AND (".
+    ( $all_query ? "( $all_query ) AND " : '' ) . "(".
     join(' OR ', map "Queue = ".$_->{Id}, @$queues)
     .")";
 $query = 'id < 0' unless @$queues;

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


More information about the rt-commit mailing list