[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-972-g75f49e5
Jesse Vincent
jesse at bestpractical.com
Mon Sep 27 22:20:08 EDT 2010
The branch, 3.9-trunk has been updated
via 75f49e588c2c30e01a5b2bab44d42fbb48da5444 (commit)
via c665d5e13892a76cab83e9150aab36632a6c5f0c (commit)
from 34eddbd458e79190a818f578191915d93b357c21 (commit)
Summary of changes:
share/html/Elements/MyAdminQueues | 6 +-
share/html/Elements/MySupportQueues | 10 +--
share/html/Elements/QueueSummary | 108 ---------------------------
share/html/Elements/QueueSummaryByLifecycle | 76 +++++++++++--------
share/html/Elements/QueueSummaryByStatus | 71 +++++++++++-------
5 files changed, 92 insertions(+), 179 deletions(-)
delete mode 100644 share/html/Elements/QueueSummary
- Log -----------------------------------------------------------------
commit c665d5e13892a76cab83e9150aab36632a6c5f0c
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Sep 27 19:56:04 2010 -0400
Minor refactoring
diff --git a/share/html/Elements/QueueSummary b/share/html/Elements/QueueSummary
index d82554f..a1393cb 100644
--- a/share/html/Elements/QueueSummary
+++ b/share/html/Elements/QueueSummary
@@ -46,21 +46,29 @@
%#
%# END BPS TAGGED BLOCK }}}
<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
+
<tr>
- <th class="collection-as-table"><&|/l&>Queue</&></th>
+ <th class="collection-as-table"><&|/l&>Queue</&></th>
% for my $condition (@$conditions) {
- <th class="collection-as-table"><% $condition->{name} %></th>
+ <th class="collection-as-table"><% $condition->{name} %></th>
% }
</tr>
-% my $i;
-% for my $queue (@queues) {
-% $i++;
-% my $name = $queue->{Name};
-% $name =~ s/'/\\'/g;
-% my $queue_cond = "Queue = '$name' AND ";
-% my $all_q = $queue_cond . "(".join( " OR ", map $_->{cond}, @$conditions).")";
+
+<%perl>
+my $i = 0;
+for my $queue (@queues) {
+ $i++;
+ my $name = $queue->{Name};
+ $name =~ s/'/\\'/g;
+ my $queue_cond = "Queue = '$name' AND ";
+
+ my $all_q = $queue_cond . "(".join( " OR ", map $_->{cond}, @$conditions).")";
+
+</%perl>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
+
<td><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a></td>
+
% for my $condition (@$conditions) {
% $Tickets->FromSQL( "Queue = $queue->{id} AND ". $condition->{cond} );
<td align="right"><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond.$condition->{cond} |u,n %>"><% $Tickets->Count %></a></td>
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 851bd80..63a1f66 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -45,9 +45,12 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-% foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
-% my @cur_statuses = grep $lifecycle->is_valid($_), @statuses;
-% next unless @cur_statuses;
+<%perl>
+ foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
+ my @cur_statuses = grep $lifecycle->is_valid($_), @statuses;
+ next unless @cur_statuses;
+</%perl>
+
<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
<tr>
@@ -66,7 +69,7 @@ for my $queue (@queues) {
my $name = $queue->{Name};
$name =~ s/'/\\'/g;
my $queue_cond = "Queue = '$name' AND ";
- my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", grep $lifecycle->is_valid($_), @statuses ) . ')';
+ my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", @cur_statuses ) . ')';
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
commit 75f49e588c2c30e01a5b2bab44d42fbb48da5444
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Sep 27 22:20:53 2010 -0400
Switch QueueSummary components to use RT::Report::Tickets.
This should dramatically cut homepge queries on RT instances with many
queues
diff --git a/share/html/Elements/MyAdminQueues b/share/html/Elements/MyAdminQueues
index 6e5aec1..eeb7859 100644
--- a/share/html/Elements/MyAdminQueues
+++ b/share/html/Elements/MyAdminQueues
@@ -46,9 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
<&|/Widgets/TitleBox, title => loc("Queues I administer"), bodyclass => "" &>
-<& /Elements/QueueSummary,
- cache => 'my_admin_queues',
+<& /Elements/QueueSummaryByStatus,
queue_filter => sub { $_->CurrentUserHasRight('AdminQueue') },
- conditions => [ {cond => "Status = 'new'", name => loc ('new') },
- {cond => "Status = 'open'", name => loc ('open') }] &>
+&>
</&>
diff --git a/share/html/Elements/MySupportQueues b/share/html/Elements/MySupportQueues
index c631603..df3df4a 100644
--- a/share/html/Elements/MySupportQueues
+++ b/share/html/Elements/MySupportQueues
@@ -46,15 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
<&|/Widgets/TitleBox, title => loc("Queues I'm an AdminCc for"), bodyclass => "" &>
-<& /Elements/QueueSummary,
- cache => 'my_support_queues',
+<& /Elements/QueueSummaryByStatus,
queue_filter => sub { $_->IsAdminCc($session{'CurrentUser'}->Id) },
- conditions => \@conditions,
&>
</&>
-<%INIT>
-my @conditions = ();
-foreach ( RT::Queue->ActiveStatusArray ) {
- push @conditions, { cond => "Status = '$_'", name => loc($_) };
-}
-</%INIT>
diff --git a/share/html/Elements/QueueSummary b/share/html/Elements/QueueSummary
deleted file mode 100644
index a1393cb..0000000
--- a/share/html/Elements/QueueSummary
+++ /dev/null
@@ -1,116 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
-%# <jesse at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
-
-<tr>
- <th class="collection-as-table"><&|/l&>Queue</&></th>
-% for my $condition (@$conditions) {
- <th class="collection-as-table"><% $condition->{name} %></th>
-% }
-</tr>
-
-<%perl>
-my $i = 0;
-for my $queue (@queues) {
- $i++;
- my $name = $queue->{Name};
- $name =~ s/'/\\'/g;
- my $queue_cond = "Queue = '$name' AND ";
-
- my $all_q = $queue_cond . "(".join( " OR ", map $_->{cond}, @$conditions).")";
-
-</%perl>
-<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-
-<td><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a></td>
-
-% for my $condition (@$conditions) {
-% $Tickets->FromSQL( "Queue = $queue->{id} AND ". $condition->{cond} );
-<td align="right"><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond.$condition->{cond} |u,n %>"><% $Tickets->Count %></a></td>
-% }
-</tr>
-% }
-</table>
-<%INIT>
-# Ensure sane default
-unless ( @$conditions ) {
- foreach (RT::Queue->ActiveStatusArray()) {
- push @$conditions, { cond => "Status = '$_'", name => loc($_) };
- }
-}
-
-
-my @queues;
-
-if ($cache && exists $session{$cache}) {
- @queues = @{$session{$cache}};
-}
-else {
- my $Queues = RT::Queues->new($session{'CurrentUser'});
- $Queues->UnLimit();
- @queues = grep $queue_filter->($_), @{$Queues->ItemsArrayRef};
-
- $m->callback( CallbackName => 'Filter', Queues => \@queues );
-
- @queues = map { {
- id => $_->Id,
- Name => $_->Name,
- Description => $_->Description,
- } } grep $_, @queues;
-
- $session{$cache} = \@queues if $cache;
-}
-
-
-my $Tickets = RT::Tickets->new($session{'CurrentUser'});
-</%INIT>
-<%ARGS>
-$cache => undef
-$queue_filter => undef
-$conditions => []
-</%ARGS>
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 63a1f66..49ef0a7 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -73,55 +73,68 @@ for my $queue (@queues) {
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-<td><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a></td>
+<td>
+ <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+</td>
% for my $status (@cur_statuses) {
-% $Tickets->FromSQL( "Queue = $queue->{id} AND Status = '$status'" );
-<td align="right"><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $Tickets->Count %></a></td>
+<td align="right">
+ <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
+</td>
% }
</tr>
% }
</table>
% }
<%INIT>
-my @queues;
-if ($cache && exists $session{$cache}) {
- @queues = @{$session{$cache}};
+my $data = {};
+my $statuses = {};
+
+use RT::Report::Tickets;
+my $report = RT::Report::Tickets->new( RT->SystemUser );
+$report->SetupGroupings( Query => 'id > 0', GroupBy => [qw(Status Queue)] );
+
+while ( my $entry = $report->Next ) {
+ $data->{ $entry->__Value("Queue") }->{ $entry->__Value("Status") }
+ = $entry->__Value('id');
+ $statuses->{ $entry->__Value("Status") } = 1;
}
-else {
- my $Queues = RT::Queues->new($session{'CurrentUser'});
- $Queues->UnLimit();
- @queues = grep $queue_filter->($_), @{$Queues->ItemsArrayRef};
- $m->callback( CallbackName => 'Filter', Queues => \@queues );
- @queues = map { {
- id => $_->Id,
- Name => $_->Name,
- Description => $_->Description,
- Lifecycle => $_->lifecycle->name,
- } } grep $_, @queues;
- $session{$cache} = \@queues if $cache;
-}
+
+my @queues;
+my $Queues = RT::Queues->new( $session{'CurrentUser'} );
+$Queues->UnLimit();
+ at queues = grep $queue_filter->($_), @{ $Queues->ItemsArrayRef };
+
+$m->callback( CallbackName => 'Filter', Queues => \@queues );
+
+ at queues = map {
+ { id => $_->Id,
+ Name => $_->Name,
+ Description => $_->Description,
+ Lifecycle => $_->lifecycle->name,
+ }
+} grep $_, @queues;
my %lifecycle;
-$lifecycle{ lc $_->name } = $_ foreach
- grep $_, map RT::Lifecycle->load($_),
- map $_->{'Lifecycle'}, @queues;
+for my $queue (@queues) {
+ my $cycle = RT::Lifecycle->load( $queue->{'Lifecycle'} );
+ $lifecycle{ lc $cycle->name } = $cycle;
+}
-unless ( @statuses ) {
+unless (@statuses) {
my %seen;
- foreach my $set('initial', 'active') {
+ foreach my $set ( 'initial', 'active' ) {
foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
- push @statuses, grep !$seen{lc $_}++, $lifecycle->$set();
+ push @statuses, grep !$seen{ lc $_ }++, $lifecycle->$set();
}
}
}
-my $Tickets = RT::Tickets->new($session{'CurrentUser'});
</%INIT>
<%ARGS>
$cache => undef
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummaryByStatus
index 387cd1b..58dce73 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -66,12 +66,17 @@ for my $queue (@queues) {
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-<td><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a></td>
+<td><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>"
+ title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+</td>
-% for my $status (@statuses) {
-% if ( $lifecycle->is_valid( $status ) ) {
-% $Tickets->FromSQL( "Queue = $queue->{id} AND Status = '$status'" );
-<td align="right"><a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $Tickets->Count %></a></td>
+<%perl>
+ for my $status (@statuses) {
+ if ( $lifecycle->is_valid( $status ) ) {
+</%perl>
+<td align="right">
+ <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $data->{$queue->{id}}->{$status} || '-'%></a>
+</td>
% } else {
<td align="right">-</td>
% }
@@ -80,47 +85,57 @@ for my $queue (@queues) {
% }
</table>
<%INIT>
+my $data = {};
+my $statuses = {};
+
+use RT::Report::Tickets;
+my $report = RT::Report::Tickets->new( RT->SystemUser );
+$report->SetupGroupings( Query => 'id > 0', GroupBy => [qw(Status Queue)] );
+
+while ( my $entry = $report->Next ) {
+ $data->{ $entry->__Value("Queue") }->{ $entry->__Value("Status") }
+ = $entry->__Value('id');
+ $statuses->{ $entry->__Value("Status") } = 1;
+}
+
my @queues;
-if ($cache && exists $session{$cache}) {
- @queues = @{$session{$cache}};
+my $Queues = RT::Queues->new( $session{'CurrentUser'} );
+$Queues->UnLimit();
+ at queues = @{ $Queues->ItemsArrayRef };
+if ($queue_filter) {
+ @queues = grep { $queue_filter->($_) } @queues;
}
-else {
- my $Queues = RT::Queues->new($session{'CurrentUser'});
- $Queues->UnLimit();
- @queues = grep $queue_filter->($_), @{$Queues->ItemsArrayRef};
- $m->callback( CallbackName => 'Filter', Queues => \@queues );
+$m->callback( CallbackName => 'Filter', Queues => \@queues );
- @queues = map { {
- id => $_->Id,
- Name => $_->Name,
- Description => $_->Description,
- Lifecycle => $_->lifecycle->name,
- } } grep $_, @queues;
+ at queues = map {
+ { id => $_->Id,
+ Name => $_->Name,
+ Description => $_->Description,
+ Lifecycle => $_->lifecycle->name,
+ }
+} grep $_, @queues;
- $session{$cache} = \@queues if $cache;
-}
my %lifecycle;
-$lifecycle{ lc $_->name } = $_ foreach
- grep $_, map RT::Lifecycle->load($_),
- map $_->{'Lifecycle'}, @queues;
+for my $queue (@queues) {
+ my $cycle = RT::Lifecycle->load( $queue->{'Lifecycle'} );
+ $lifecycle{ lc $cycle->name } = $cycle;
+}
-unless ( @statuses ) {
+unless (@statuses) {
my %seen;
- foreach my $set('initial', 'active') {
+ foreach my $set ( 'initial', 'active' ) {
foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
- push @statuses, grep !$seen{lc $_}++, $lifecycle->$set();
+ push @statuses, grep !$seen{ lc $_ }++, $lifecycle->$set();
}
}
}
-my $Tickets = RT::Tickets->new($session{'CurrentUser'});
</%INIT>
<%ARGS>
-$cache => undef
$queue_filter => undef
@statuses => ()
</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list