Discrepancy in Ticket count and Next / Previous pagelinks on Search->Display page

I’d also run into the problem and mentioned it on the list. I offered a
solution, but was told that it wasn’t worth the performance hit to
report accurate information. In case you are interested, I’ll provide
here any way.

I created a new subroutine in lib/RT/Tickets_Overlay.pm:

  • {{{ sub NumTickets

  • sub NumTickets {
  • my $self = shift;
    
  • my $i = 0;
    
  • while ($self->Next) {
    
  •   $i++;
    
  • }
    
  • return $i;
    
  • }
  • }}}

Then changed this line in share/html/Search/Results.html:

$ticketcount = $session{tickets}->CountAll();

to

$ticketcount = $session{tickets}->NumTickets();

Lastly, I modified share/html/Elements/TicketList as such (bear in mind
that I’ve made other mods to the file, so my line numbering may not
match up with yours):

@@ -59,12 +59,12 @@
maxitems => $maxitems &>
% }

-% my $i;
+% my $TotalFound;
% while (my $record = $Collection->Next) {
-% $i++;
+% $TotalFound++;
% # Every ten rows, flush the buffer and put something on the page.
-% $m->flush_buffer() unless ($i % 10);
-<& /Elements/CollectionAsTable/Row, Format => @Format, i => $i,
record => $record, maxitems => $maxitems &>
+% $m->flush_buffer() unless ($TotalFound % 10);
+<& /Elements/CollectionAsTable/Row, Format => @Format, i =>
$TotalFound, record => $record, maxitems => $maxitems &>
% }

@@ -137,7 +137,6 @@ $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); $Collection->RowsPerPage($Rows) if ($Rows); $Collection->GotoPage($Page-1); # SB uses page 0 as the first page -my $TotalFound = $Collection->CountAll();

</%INIT>
<%ARGS>-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Himanshu
Agrawal
Sent: Thursday, July 13, 2006 2:46 AM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Discrepancy in Ticket count and Next / Previous
pagelinks on Search->Display page

After performing a search, the results page displays ‘Found X Tickets’
as heading. This count includes tickets for which the user does not have
‘Show Ticket’ rights.

To reproduce:

  1. Create a user (say TestUser) and a queue (say TestQueue) such that
    TestUser has rights only in TestQueue.
  2. Create a ticket in TestQueue, say Test Ticket.
  3. Perform a search - Queue = ‘TestQueue’

The Ticket count displayed in heading will not match the actual number
of tickets displayed on results page. Also, as TestQueue contains only a
single ticket, so Next and Previous page links should not be visible.

I am not proficient in Perl and could not infer much from
rt3/share/html/Search/Results.html and
rt3/share/html/Elements/ListActions scripts. Please point me right
direction.

I’m using RT 3.4 on Linux RedHat 9 with Apache 2 and Perl 5.8.8.

Thanks and regards,
Himanshu Agrawal
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

We’re hiring! Come hack Perl for Best Practical:
http://bestpractical.com/about/jobs.html

Thanks for your inputs and apologies for reply after so long.

I tried the changes you mentioned but did not get the full desired
functionality. It corrects the count in ‘Found X tickets’ but messes up
the Next / Previous page links.
Elaborate it bit more:
Suppose total found tickets is 200; rows parameter is set to 50 for
search result page and the user can see-----Original Message-----
From: Schultz, Eric [mailto:ESchultz@corp.untd.com]
Sent: Friday, July 14, 2006 21:20
To: Himanshu Agrawal; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Discrepancy in Ticket count and Next / Previous
pagelinks on Search->Display page

I’d also run into the problem and mentioned it on the list. I offered a
solution, but was told that it wasn’t worth the performance hit to
report accurate information. In case you are interested, I’ll provide
here any way.

I created a new subroutine in lib/RT/Tickets_Overlay.pm:

  • {{{ sub NumTickets

  • sub NumTickets {
  • my $self = shift;
    
  • my $i = 0;
    
  • while ($self->Next) {
    
  •   $i++;
    
  • }
    
  • return $i;
    
  • }
  • }}}

Then changed this line in share/html/Search/Results.html:

$ticketcount = $session{tickets}->CountAll();

to

$ticketcount = $session{tickets}->NumTickets();

Lastly, I modified share/html/Elements/TicketList as such (bear in mind
that I’ve made other mods to the file, so my line numbering may not
match up with yours):

@@ -59,12 +59,12 @@
maxitems => $maxitems &>
% }

-% my $i;
+% my $TotalFound;
% while (my $record = $Collection->Next) {
-% $i++;
+% $TotalFound++;
% # Every ten rows, flush the buffer and put something on the page.
-% $m->flush_buffer() unless ($i % 10);
-<& /Elements/CollectionAsTable/Row, Format => @Format, i => $i,
record => $record, maxitems => $maxitems &>
+% $m->flush_buffer() unless ($TotalFound % 10);
+<& /Elements/CollectionAsTable/Row, Format => @Format, i =>
$TotalFound, record => $record, maxitems => $maxitems &>
% }

@@ -137,7 +137,6 @@ $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); $Collection->RowsPerPage($Rows) if ($Rows); $Collection->GotoPage($Page-1); # SB uses page 0 as the first page -my $TotalFound = $Collection->CountAll();

</%INIT>
<%ARGS>

Sorry again, I didn’t finish it.

Suppose total found tickets is 200;
rows parameter is set to 50 for search result page;
the logged in user can see only 5 tickets out of 200, but these tickets
get displayed on 3rd page.;

In this scenario, the count is displayed as 5; the results page does not
list any tickets and Next / Previous page links does not show up.

I will appreciate any inputs on the same.

Thanks

Himanshu Agrawal-----Original Message-----
From: Himanshu Agrawal
Sent: Friday, July 21, 2006 11:40
To: ‘Schultz, Eric’; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Discrepancy in Ticket count and Next / Previous
pagelinks on Search->Display page

Thanks for your inputs and apologies for reply after so long.

I tried the changes you mentioned but did not get the full desired
functionality. It corrects the count in ‘Found X tickets’ but messes up
the Next / Previous page links.
Elaborate it bit more:
Suppose total found tickets is 200; rows parameter is set to 50 for
search result page and the user can see

-----Original Message-----
From: Schultz, Eric [mailto:ESchultz@corp.untd.com]
Sent: Friday, July 14, 2006 21:20
To: Himanshu Agrawal; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Discrepancy in Ticket count and Next / Previous
pagelinks on Search->Display page

I’d also run into the problem and mentioned it on the list. I offered a
solution, but was told that it wasn’t worth the performance hit to
report accurate information. In case you are interested, I’ll provide
here any way.

I created a new subroutine in lib/RT/Tickets_Overlay.pm:

  • {{{ sub NumTickets

  • sub NumTickets {
  • my $self = shift;
    
  • my $i = 0;
    
  • while ($self->Next) {
    
  •   $i++;
    
  • }
    
  • return $i;
    
  • }
  • }}}

Then changed this line in share/html/Search/Results.html:

$ticketcount = $session{tickets}->CountAll();

to

$ticketcount = $session{tickets}->NumTickets();

Lastly, I modified share/html/Elements/TicketList as such (bear in mind
that I’ve made other mods to the file, so my line numbering may not
match up with yours):

@@ -59,12 +59,12 @@
maxitems => $maxitems &>
% }

-% my $i;
+% my $TotalFound;
% while (my $record = $Collection->Next) {
-% $i++;
+% $TotalFound++;
% # Every ten rows, flush the buffer and put something on the page.
-% $m->flush_buffer() unless ($i % 10);
-<& /Elements/CollectionAsTable/Row, Format => @Format, i => $i,
record => $record, maxitems => $maxitems &>
+% $m->flush_buffer() unless ($TotalFound % 10);
+<& /Elements/CollectionAsTable/Row, Format => @Format, i =>
$TotalFound, record => $record, maxitems => $maxitems &>
% }

@@ -137,7 +137,6 @@ $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); $Collection->RowsPerPage($Rows) if ($Rows); $Collection->GotoPage($Page-1); # SB uses page 0 as the first page -my $TotalFound = $Collection->CountAll();

</%INIT>
<%ARGS>