[rt-users] Limit on queues display

Ruslan U. Zakirov cubic at acronis.ru
Fri May 28 11:01:16 EDT 2004


Emmanuel Lacour wrong:
> Hi,
> 
> I've got a QuickSearch wich show me only queues with respective
> new,open,reolved,stalled and rejected tickets count.
> 
> I've got a lot of queues... and I would like to print only queues with
> at least 1 ticket new or open or stalled.
> 
> I did a quick hack on Quicksearch to do this:
> 
You can do it in one select:
       $Tickets->ClearRestrictions;
       $Tickets->LimitStatus(VALUE => "open");
       $Tickets->LimitStatus(VALUE => "new");
       $Tickets->LimitStatus(VALUE => "stalled");
       $Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
       next unless( $Tickets->Count() );
>      $Tickets->ClearRestrictions;
>      $Tickets->LimitStatus(VALUE => "open");
>      $Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
>      my $open = $Tickets->Count();
> 
>      $Tickets->ClearRestrictions;
>      $Tickets->LimitStatus(VALUE => "new");
>      $Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
>      my $new = $Tickets->Count();
> 
>      $Tickets->ClearRestrictions;
>      $Tickets->LimitStatus(VALUE => "stalled");
>      $Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
>      my $stalled = $Tickets->Count();
> 
> 
> But this way is slow because the limit occur in perl, not in sql I think...

You think wrong. Limit* is perl subs which push conditions on stack and 
only when you call Count or some fetch op(First, Next...) RT/DBIx::SB 
generate SQL query that fetch info from DB.

> 
> Is there a way to do this directly with somethink like a $Queue ->Limit??? statement.
> (I think it could be better because SearchBuilder will do a more efficient job)
No way, since Queue table doesn't contain info about amount of tickets. 
Most efficient way is GROUP BY with COUNT(), but DBIx::SB doesn't 
support it yet.

> 
> Thanks for any help.
> 

				Best regards. Ruslan.



More information about the rt-users mailing list