Created
December 12, 2010 11:11
-
-
Save akaihola/737979 to your computer and use it in GitHub Desktop.
Extend the RT (RequestTracker) REST API with a search. Use date range and queue name as search filters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This extension adds a date and queue based search to the REST API. | |
Copyright 2010 Antti Kaihola | |
This software is distributed under the New BSD license. | |
Source repository for the extension: | |
https://gist.github.com/737979 | |
Usage: | |
1. create the directory | |
``/usr/local/share/request-tracker3.8/html/REST/1.0/search`` | |
2. copy the ``html/REST/1.0/search/transaction`` Perl source file into | |
the created directory | |
3. restart your webserver | |
This extension was created to be used together with the | |
RTTicketTimeline plugin on a Trac server (see | |
https://gist.github.com/737989). | |
-Antti Kaihola | |
<akaihol plus-sign rt at-sign ambitone dot-sign com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%# BEGIN BPS TAGGED BLOCK {{{ | |
%# | |
%# COPYRIGHT: | |
%# | |
%# This software is Copyright (c) 2010 Antti Kaihola | |
%# <akaihol plus-sign rt at-sign ambitone dot-sign com> | |
%# | |
%# | |
%# LICENSE: | |
%# | |
%# This work is made available to you under the terms of the New BSD | |
%# license. | |
%# | |
%# END BPS TAGGED BLOCK }}} | |
%# REST/1.0/search/transaction | |
%# | |
<%ARGS> | |
$from => undef | |
$to => undef | |
$queue => undef | |
</%ARGS> | |
<%INIT> | |
use RT::Interface::REST; | |
my $trans = new RT::Transactions $session{CurrentUser}; | |
my $ticketTable = $trans->NewAlias('Tickets'); | |
my $queueTable = $trans->NewAlias('Queues'); | |
$trans->Limit(FIELD => 'ObjectType', | |
VALUE => 'RT::Ticket'); | |
$trans->Join(ALIAS1 => 'main', | |
FIELD1 => 'ObjectId', | |
ALIAS2 => $ticketTable, | |
FIELD2 => 'id'); | |
$trans->Join(ALIAS1 => $ticketTable, | |
FIELD1 => 'Queue', | |
ALIAS2 => $queueTable, | |
FIELD2 => 'id'); | |
$trans->Limit(FIELD => 'Created', | |
OPERATOR => '>=', | |
VALUE => $from); | |
$trans->Limit(FIELD => 'Created', | |
OPERATOR => '<=', | |
VALUE => $to, | |
ENTRYAGGREGATOR => 'AND'); | |
$trans->Limit(ALIAS => $queueTable, | |
FIELD => 'Name', | |
OPERATOR => '=', | |
VALUE => $queue, | |
ENTRYAGGREGATOR => 'AND'); | |
$trans->OrderByCols( { FIELD => 'Created', | |
ORDER => 'ASC' }, | |
{ FIELD => 'id', | |
ORDER => 'ASC' } ); | |
while (my $t = $trans->Next) { | |
$m->out($t->Created . ' #' . $t->ObjectId . ' ' . $t->Description . "\n"); | |
} | |
return(); | |
</%INIT> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment