Skip to content

Commit

Permalink
Limit query to active/inactive tickets in QueueList based on passed i…
Browse files Browse the repository at this point in the history
…n @Statuses

In 8ef6b45, 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
  • Loading branch information
sunnavy committed May 11, 2021
1 parent 881f360 commit ddcd842
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions share/html/Elements/QueueSummaryByLifecycle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ddcd842

Please sign in to comment.