Commit 591dfd01 authored by Jesse Vincent's avatar Jesse Vincent
Browse files

r1999@tinbook: jesse | 2004-06-28T15:23:21.837515Z

Performance improvements and code cleanups to the Lookup tool

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/rtir/trunk@1162 e417ac7c-1bcc-0310-8ffa-8f5827389a85
parent eb5d1af8
......@@ -75,4 +75,11 @@ Set($_RTIR_Constituency_default, "EDUNET");
# Set($ReplyString , "Re:");
# RTIR_OldestRelatedTickets controls how far back, in days, RTIR
# should look for tickets which might contain a specific string,
# such as an IP address.
Set($RTIR_OldestRelatedTickets, 60);
1;
......@@ -24,11 +24,11 @@
%# END LICENSE BLOCK
<TABLE width=100% border=0 cellpadding=2 CELLSPACING=0>
<TR>
<td><b><&|/l&>id<b></&></td>
<td><b><&|/l&>Subject<b></&></td>
<td><b><&|/l&>State<b></&></td>
<td><b><&|/l&>Priority<b></&></td>
<td align=right><b><&|/l&>Actions<b></&></td>
<th><b><&|/l&>id<b></&></th>
<th><b><&|/l&>Subject<b></&></th>
<th><b><&|/l&>State<b></&></th>
<th><b><&|/l&>Priority<b></&></th>
<th align=right><b><&|/l&>Actions<b></&></th>
</TR>
% my $i=0;
%while (my $Ticket = $session{'tickets'}->Next) {
......
......@@ -39,30 +39,55 @@
<hr>
% }
%if (! $ARGS{'HideResults'}) {
% unless ( $ARGS{'HideResults'}) {
<TABLE WIDTH=100% border=0 cellpadding=2 CELLSPACING=0>
<tr><td valign=top width=50%>
<& /Elements/TitleBoxStart, title => loc('Incidents: [_1]', $q) &>
<& /RTIR/Elements/IncidentSummary, Type => $TicketType, ticket => $ticket, q => $q &>
<& /Elements/TitleBoxEnd&>
<& /Elements/TitleBoxStart,
title => loc('Incidents: [_1]', $q) &>
<& /RTIR/Elements/IncidentSummary,
Type => $TicketType,
ticket => $ticket,
q => $q &>
<& /Elements/TitleBoxEnd &>
<br>
<& /Elements/TitleBoxStart, title => loc('Incident Reports: [_1]', $q), color=> "#336633"&>
<& /RTIR/Elements/ChildSummary, Queue => 'Incident Reports', Type => $TicketType, ticket => $ticket, lookuptype => $type, q => $q &>
<& /Elements/TitleBoxStart,
title => loc('Incident Reports: [_1]', $q),
color=> "#336633"&>
<& /RTIR/Elements/ChildSummary,
Queue => 'Incident Reports',
Type => $TicketType,
ticket => $ticket,
lookuptype => $type,
q => $q &>
<& /Elements/TitleBoxEnd&>
</td><td width=50% valign=top>
<& /Elements/TitleBoxStart, title => loc('Investigations: [_1]', $q), color=> "#336633" &>
<& /RTIR/Elements/ChildSummary, Queue => 'Investigations', Type => $TicketType, ticket => $ticket, lookuptype => $type, q => $q &>
<& /Elements/TitleBoxStart,
title => loc('Investigations: [_1]', $q),
color=> "#336633" &>
<& /RTIR/Elements/ChildSummary,
Queue => 'Investigations',
Type => $TicketType,
ticket => $ticket,
lookuptype => $type,
q => $q &>
<& /Elements/TitleBoxEnd &>
<br>
<& /Elements/TitleBoxStart, title => loc('Blocks: [_1]', $q), color=> "#336633" &>
<& /RTIR/Elements/ChildSummary, Queue => 'Blocks', Type => $TicketType, ticket => $ticket, lookuptype => $type, q => $q &>
<& /Elements/TitleBoxStart,
title => loc('Blocks: [_1]', $q),
color=> "#336633" &>
<& /RTIR/Elements/ChildSummary,
Queue => 'Blocks',
Type => $TicketType,
ticket => $ticket,
lookuptype => $type,
q => $q &>
<& /Elements/TitleBoxEnd &>
</TABLE>
% }
......@@ -136,6 +161,13 @@ parse this data.
% }
<%init>
my $title = loc("Lookup '[_1]' using server [_2]", $q, $server);
my $current_subtab;
my $TicketType;
my $TicketObj;
# {{{ Set up the whois query
foreach my $s (sort keys %$servers) {
# just pick the first one
$server = $servers->{$s} unless ($server);
......@@ -148,42 +180,39 @@ my ($iterator, $error);
if ($query) {
$iterator = $query->query_iterator($q);
} else {
$error = "Unable to connect to whois server '$server'";
$error = loc( "Unable to connect to WHOIS server '[_1]'", $server);
}
$ARGS{'ClearRestrictions'}="1";
$ARGS{'AttachmentField'}="Content";
$ARGS{'AttachmentFieldOp'}="LIKE";
$ARGS{'ValueOfAttachmentField'}=$q;
if (! $session{'tickets'}) {
# Init a new search
$session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
}
# }}}
my $title = "Lookup $q using server $server";
my $ticketcount;
$session{'i'}++;
if ($session{'tickets'}) {
if ($ARGS{'DeleteRestriction'}) {
$session{'tickets'}->DeleteRestriction($ARGS{'DeleteRestriction'});
my $max_age;
if ($RT::RTIR_OldestRelatedTickets) {
$max_age = 0 - $RT::RTIR_OldestRelatedTickets;
} else {
$max_age = -60;
}
if ( ($ARGS{'ClearRestrictions'}) || ($ARGS{'NewSearch'}) ) {
$session{'tickets'}->ClearRestrictions;
}
}
ProcessSearchQuery(ARGS=>\%ARGS);
$session{'tickets'}->RedoSearch();
if ( $session{'tickets'}->DescribeRestrictions()) {
$ticketcount = $session{tickets}->Count();
}
my $current_subtab;
my $now = RT::Date->new($session{'CurrentUser'});
$now->SetToNow();
$now->AddDays($max_age);
# Init a new search
$session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
if ($q) {
$current_subtab = 'RTIR/Tools/Lookup.html?q='.$q."&server=".$server;
my ( $val, $msg ) =
$session{'tickets'}->FromSQL(
"( ContentType = 'text/plain' "
. "OR ContentType = 'text' "
. "OR ContentType = 'text/html' )"
. " AND Content LIKE '$q' "
. " AND TransactionDate > '"
. $now->ISO
. "'" );
}
my $TicketType;
my $TicketObj;
if ($ticket) {
$TicketType = $m->scomp("/RTIR/Elements/Type", Ticket => $ticket);
$TicketType =~ s/\s*$//;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment