[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-27-ge0d707d

Jesse Vincent jesse at bestpractical.com
Thu Sep 30 00:22:42 EDT 2010


The branch, 3.9-trunk has been updated
       via  e0d707ddfaa809b379387e4bce87a9b8f39ca21b (commit)
      from  9c250a491880e31b81979d589603cccc3c481a92 (commit)

Summary of changes:
 share/html/Ticket/Display.html              |    3 +++
 share/html/Ticket/Elements/FindTransactions |   25 +++++++++++++++++++++++++
 share/html/Ticket/Elements/ShowHistory      |   21 +++------------------
 3 files changed, 31 insertions(+), 18 deletions(-)
 create mode 100644 share/html/Ticket/Elements/FindTransactions

- Log -----------------------------------------------------------------
commit e0d707ddfaa809b379387e4bce87a9b8f39ca21b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Sep 30 00:14:27 2010 -0400

    Precache the transactions we're searching for on a ticket display page
    to cut down on repeated SQL queries on ticket display

diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 22d2b9a..43e834a 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -76,6 +76,7 @@
     <& /Ticket/Elements/ShowHistory ,
           Ticket => $TicketObj,
           Tickets => $Tickets,
+          Transactions => $transactions,
           Collapsed => $ARGS{'Collapsed'},
           ShowHeaders => $ARGS{'ShowHeaders'},
           Attachments => $attachments,
@@ -202,6 +203,8 @@ $m->comp(
     ARGSRef     => \%ARGS
 );
 
+# Get the transactoins before the attachments, for great ACL justice
+my $transactions = $m->comp('Elements/FindTransactions',Ticket => $TicketObj, Tickets => $Tickets || undef);
 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
 my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
 
diff --git a/share/html/Ticket/Elements/FindTransactions b/share/html/Ticket/Elements/FindTransactions
new file mode 100644
index 0000000..1d83fb8
--- /dev/null
+++ b/share/html/Ticket/Elements/FindTransactions
@@ -0,0 +1,25 @@
+<%INIT>
+my $Transactions = RT::Transactions->new($session{'CurrentUser'});
+if ($Tickets) {
+    while (my $t = $Tickets->Next) {
+        $Transactions->LimitToTicket($t->id);
+    }
+} else {
+    $Transactions = $Ticket->Transactions;
+}
+
+
+my $OldestFirst = RT->Config->Get( 'OldestTransactionsFirst', $session{'CurrentUser'} );
+my $SortOrder = $OldestFirst? 'ASC': 'DESC';
+$Transactions->OrderByCols( { FIELD => 'Created',
+                              ORDER => $SortOrder },
+                            { FIELD => 'id',
+                              ORDER => $SortOrder },
+                          );
+$Transactions->Next(); $Transactions->GotoFirstItem(); # actually do the search
+return ($Transactions);
+</%INIT>
+<%ARGS>
+$Ticket => undef
+$Tickets => undef
+</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowHistory b/share/html/Ticket/Elements/ShowHistory
index d593a03..ac4dfbd 100755
--- a/share/html/Ticket/Elements/ShowHistory
+++ b/share/html/Ticket/Elements/ShowHistory
@@ -104,7 +104,7 @@ while ( my $Transaction = $Transactions->Next ) {
 
    
     my $IsLastTransaction = 0;
-    if ( $OldestFirst ) {
+    if ( RT->Config->Get( 'OldestTransactionsFirst', $session{'CurrentUser'} )){
         $IsLastTransaction = $Transactions->IsLast;
     } else {
         $IsLastTransaction = 1 if ( $i == 1 );
@@ -135,25 +135,9 @@ $m->flush_buffer();
 </div>
 % }
 <%INIT>
-my $Transactions = RT::Transactions->new($session{'CurrentUser'});
-if ($Tickets) {
-    while (my $t = $Tickets->Next) {
-        $Transactions->LimitToTicket($t->id);
-    }
-} else {
-    $Transactions = $Ticket->Transactions;
-}
-
-
-my $OldestFirst = RT->Config->Get( 'OldestTransactionsFirst', $session{'CurrentUser'} );
-my $SortOrder = $OldestFirst? 'ASC': 'DESC';
-$Transactions->OrderByCols( { FIELD => 'Created',
-                              ORDER => $SortOrder },
-                            { FIELD => 'id',
-                              ORDER => $SortOrder },
-                          );
 
 my $i;
+$Transactions ||= $m->comp('/Ticket/Elements/FindTransactions',Ticket => $Ticket, Tickets => $Tickets || undef);
 $Attachments ||=  $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket, Tickets => $Tickets || undef);
 $AttachmentContent ||= $m->comp('/Ticket/Elements/LoadTextAttachments', Ticket => $Ticket);
 
@@ -162,6 +146,7 @@ $AttachmentContent ||= $m->comp('/Ticket/Elements/LoadTextAttachments', Ticket =
 $URIFile => RT->Config->Get('WebPath')."/Ticket/Display.html"
 $Ticket => undef
 $Tickets => undef
+$Transactions => undef
 $Attachments => undef
 $AttachmentContent => undef
 $ShowHeaders => undef

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


More information about the Rt-commit mailing list