Report for original queue count

How would I write a report to count the number of tickets created in a queue? Many of our tickets are moved to other queues and I don’t know how to get counts on the original queue the ticket was created in.

Thanks

How would I write a report to count the number of tickets created in a
queue? Many of our tickets are moved to other queues and I don’t know
how to get counts on the original queue the ticket was created in.

I am tasked with a similar problem. My approach is to search for
Transactions where the Queue Field has been changed, something like
this:

----- snip - snip -------------------------------------------------
my $queuename = ‘myqueue’;
CleanEnv();
RT::LoadConfig();
RT::Init();
my $user = RT->SystemUser;
my $queue = new RT::Queue($user);
$queue->Load($queuename);

my $objs = RT::Transactions->new( $user );

$objs->Limit( FIELD => ‘ObjectType’, VALUE => “RT::Ticket”, ENTRYAGGREGATOR => ‘AND’);
$objs->Limit( FIELD => ‘Field’, VALUE => “Queue”, ENTRYAGGREGATOR => ‘AND’ );
$objs->Limit( FIELD => ‘OldValue’, VALUE => $queue->Id, ENTRYAGGREGATOR => ‘AND’ );
$objs->OrderBy( FIELD => ‘Created’);
my $ticket = RT::Ticket->new($user);
while (my $t = $objs->Next) {
$ticket->Load ($t->ObjectId);
}

----- snip - snip -------------------------------------------------

This is a sledgehammer approach, I know. If you have a many
tickets/transactions, the query could take a long time.

In my case I want to restrict the search to a given timeperiod, aka: “How
many tickets where moved out of queue yesterday”)

Hope this helps.

  • Vegard V -

my $ticket = RT::Ticket->new($user);
while (my $t = $objs->Next) {
$ticket->Load ($t->ObjectId);
}

You may appreciate my $ticket = $t->Object as a shortcut

This is a sledgehammer approach, I know. If you have a many
tickets/transactions, the query could take a long time.

You may benefit from additional indexes, if this is something you do
frequently (or the database slow query logs tell you when you hit
that).

In my case I want to restrict the search to a given timeperiod, aka: “How
many tickets where moved out of queue yesterday”)

It wasn’t clear from your code if you know how to do that in the
query, or if you’re just stopping the iteration when you get far
enough back.

-kevin

my $ticket = RT::Ticket->new($user);
while (my $t = $objs->Next) {
$ticket->Load ($t->ObjectId);
}

You may appreciate my $ticket = $t->Object as a shortcut

Ah, much preferred, thanks for the tip.

This is a sledgehammer approach, I know. If you have a many
tickets/transactions, the query could take a long time.

You may benefit from additional indexes, if this is something you do
frequently (or the database slow query logs tell you when you hit
that).

Yup. In my case this isn’t a problem, but it might be for others.

In my case I want to restrict the search to a given timeperiod, aka: “How
many tickets where moved out of queue yesterday”)

It wasn’t clear from your code if you know how to do that in the
query, or if you’re just stopping the iteration when you get far
enough back.

In my own version of the script, I have additional code for limiting
against ‘Created’. The original poster did not seem to have similar
requirements, so I left that out from the example.

  • Vegard V -