[Rt-commit] [rtir] 05/24: Additional work porting from queue-based ticket typing to lifecycle-based ticket typing
Jesse Vincent
jesse at bestpractical.com
Mon Feb 9 00:25:17 EST 2015
This is an automated email from the git hooks/post-receive script.
jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.
commit 61c6f8fc544b7fb29d8540546ffafc3bc3cade90
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Fri Feb 6 14:58:58 2015 -0800
Additional work porting from queue-based ticket typing to lifecycle-based ticket typing
---
html/RTIR/Elements/MergeWith | 10 +++++-----
html/RTIR/Merge/index.html | 30 ++++++++++++++--------------
html/RTIR/Reporting/Report.html | 8 ++++----
lib/RT/IR.pm | 44 ++++++++++++++++++++++++++++++-----------
4 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/html/RTIR/Elements/MergeWith b/html/RTIR/Elements/MergeWith
index ae68e1a..1d67765 100644
--- a/html/RTIR/Elements/MergeWith
+++ b/html/RTIR/Elements/MergeWith
@@ -47,7 +47,7 @@
%# END BPS TAGGED BLOCK }}}
<h3><% $Title %></h3>
<& /RTIR/Search/Elements/ShowResults,
- Queue => $Queue,
+ Lifecycle => $Lifecycle,
BaseQuery => $BaseQuery,
Query => $Query,
DisplayFormat => "__RadioButton__, $Format",
@@ -60,18 +60,18 @@
&>
<%INIT>
-my $Type = RT::IR::TicketType( Queue => $Queue );
+my $Type = RT::IR::TicketType( Lifecycle => $Lifecycle );
$Title ||= $Type .'s';
-$Query ||= RT::IR->ActiveQuery( Queue => $Queue );
-$BaseQuery ||= RT::IR->Query( Queue => $Queue, Exclude => $id );
+$Query ||= RT::IR->ActiveQuery( Lifecycle => $Lifecycle );
+$BaseQuery ||= RT::IR->Query( Lifecycle => $Lifecycle, Exclude => $id );
</%INIT>
<%ARGS>
$id => undef
$Ticket => undef
-$Queue => undef
+$Lifecycle => undef
$Title => ''
$Format => undef
diff --git a/html/RTIR/Merge/index.html b/html/RTIR/Merge/index.html
index 3132ea3..17f934b 100644
--- a/html/RTIR/Merge/index.html
+++ b/html/RTIR/Merge/index.html
@@ -67,12 +67,12 @@
&>
% }
-<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Queue => $Ticket->QueueObj->Name, Ticket => $Ticket &>
+<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => $Ticket->QueueObj->Lifecycle, Ticket => $Ticket &>
% if ( $Type eq 'Report' ) {
-<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Queue => "Investigations", Ticket => $Ticket &>
+<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => "investigations", Ticket => $Ticket &>
% } elsif ( $Type eq 'Investigation' ) {
-<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Queue => "Incident Reports", Ticket => $Ticket &>
+<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => "incident_reports", Ticket => $Ticket &>
% }
<& /Elements/Submit, Caption=> loc('Merge into selected Ticket'), Label => loc("Merge") &>
</form>
@@ -89,10 +89,10 @@ $MergeTicket = LoadTicket( $SelectedTicket ) if $SelectedTicket;
my (@results);
my $checks_failure = 0;
if ( $MergeTicket ) {
- my @queues = sort map $_->Name, $Ticket->QueueObj, $MergeTicket->QueueObj;
+ my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj;
unless (
- $queues[0] eq $queues[1]
- or ($queues[0] eq "Incident Reports" and $queues[1] eq "Investigations")
+ $lifecycles[0] eq $lifecycles[1]
+ or ($lifecycles[0] eq "incident_reports" and $lifecycles[1] eq "investigations")
) {
push @results, loc("Merge failed: Ticket #[_1] is not the right type", $MergeTicket->Id );
$checks_failure = 1;
@@ -101,8 +101,8 @@ if ( $MergeTicket ) {
if ( $MergeTicket && !$checks_failure ) {
- my @queues = sort map $_->Name, $Ticket->QueueObj, $MergeTicket->QueueObj;
- if ( $queues[0] ne $queues[1] && $queues[1] eq "Incident Reports" ) {
+ my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj;
+ if ( $lifecycles[0] ne $lifecycles[1] && $lifecycles[1] eq "incident_reports" ) {
# We always want to merge into the Investigation
($Ticket, $MergeTicket) = ($MergeTicket, $Ticket);
}
@@ -129,12 +129,12 @@ if ( $MergeTicket && !$checks_failure ) {
}
my $Type = RT::IR::TicketType( Ticket => $Ticket );
-my $Queue = $Ticket->QueueObj->Name;
+my $Lifecycle = $Ticket->QueueObj->Lifecycle;
my $title = loc("Merge [_1] #[_2]: [_3]", $Type, $id, $Ticket->Subject);
-$Query ||= RT::IR->ActiveQuery( Queue => $Queue );
-my $BaseQuery = RT::IR->Query( Queue => $Queue, Exclude => $id);
+$Query ||= RT::IR->ActiveQuery( Lifecycle => $Lifecycle );
+my $BaseQuery = RT::IR->Query( Lifecycle => $Lifecycle, Exclude => $id);
my %defaults = (
Format => $Format,
@@ -148,11 +148,11 @@ my $siblings_query = '';
if ( $Type ne 'Incident' ) {
my @parents = @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] };
if ( @parents ) {
- my @queues = ($Queue);
- push @queues, 'Investigations' if $Type eq 'Report';
- push @queues, 'Incident Reports' if $Type eq 'Investigation';
+ my @lifecycles = ($Lifecycle);
+ push @lifecycles, 'investigations' if $Type eq 'Report';
+ push @lifecycles, 'incident_reports' if $Type eq 'Investigation';
$siblings_query = RT::IR->Query(
- Queue => \@queues,
+ Lifecycle => \@lifecycles,
MemberOf => \@parents,
Exclude => $id
);
diff --git a/html/RTIR/Reporting/Report.html b/html/RTIR/Reporting/Report.html
index 327c873..25f2447 100644
--- a/html/RTIR/Reporting/Report.html
+++ b/html/RTIR/Reporting/Report.html
@@ -162,12 +162,12 @@ my @classifications;
# of new reports outstanding at start of the period
my $outstanding = RT::Tickets->new( $session{'CurrentUser'} );
-$outstanding->FromSQL("Queue = 'Incident Reports' AND Created < '$start' AND (Resolved = '1970-01-01 00:00:01' OR Resolved > '$start')");
+$outstanding->FromSQL("Lifecycle = 'incident_Reports' AND Created < '$start' AND (Resolved = '1970-01-01 00:00:01' OR Resolved > '$start')");
my $outstanding_pruned = $outstanding;
# of new reports created during the period
my $tix_created = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_created->FromSQL("Queue = 'Incident Reports' AND Created > '$start' AND Created < '$end'");
+$tix_created->FromSQL("Lifecycle = 'incident_reports' AND Created > '$start' AND Created < '$end'");
my $tix_created_pruned = $tix_created_pruned;
# of new reports resolved/closed/deleted during the period
@@ -175,7 +175,7 @@ my $tix_created_pruned = $tix_created_pruned;
# also closed during the period(or before which is insane but possible)"
my $tix_resolved = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_resolved->FromSQL("Queue = 'Incident Reports' AND Created > '$start' AND Created < '$end' AND (Resolved > '1970-01-01 00:00:01' AND Resolved < '$end')");
+$tix_resolved->FromSQL("Lifecycle = 'incident_reports' AND Created > '$start' AND Created < '$end' AND (Resolved > '1970-01-01 00:00:01' AND Resolved < '$end')");
my $tix_resolved_pruned = $tix_resolved;
# of new reports oustanding at end of the period
@@ -183,7 +183,7 @@ my $tix_resolved_pruned = $tix_resolved;
# closed during the period"
my $tix_unresolved = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_unresolved->FromSQL("Queue = 'Incident Reports' AND Created > '$start' AND Created < '$end' AND ( Resolved = '1970-01-01 00:00:01' OR Resolved > '$end' )");
+$tix_unresolved->FromSQL("Lifecycle = 'incident_reports' AND Created > '$start' AND Created < '$end' AND ( Resolved = '1970-01-01 00:00:01' OR Resolved > '$end' )");
my $tix_unresolved_pruned = $tix_unresolved;
if ( $TextReport ) {
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 6cb8dfe..8c21b37 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -68,6 +68,7 @@ my %QUEUES = map { lc($_) => $_ } @QUEUES;
my %TYPE = (
'incidents' => 'Incident',
'incident reports' => 'Report',
+ 'incident_reports' => 'Report',
'investigations' => 'Investigation',
'blocks' => 'Block',
);
@@ -130,10 +131,20 @@ Returns empty string if queue is not one of RTIR's.
sub OurQueue {
my $self = shift;
my $queue = shift;
- $queue = $queue->Name if ref $queue;
- return undef unless $queue;
- return '' unless $QUEUES{ lc $queue };
- return $TYPE{ lc $queue };
+
+ my $lifecycle;
+
+ if (ref $queue) {
+ $lifecycle = $queue->Lifecycle;
+ } else {
+ my $temp_queue = RT::Queue->new(RT->SystemUser);
+ $temp_queue->Load($queue);
+ $lifecycle = $temp_queue->Lifecycle
+ }
+
+ return undef unless $lifecycle;
+ return '' unless defined $TYPE{ $lifecycle };
+ return $TYPE{ $lifecycle };
}
=head2 Types
@@ -159,7 +170,7 @@ sub Queues {
=head2 TicketType
-Returns type of a ticket. Takes either Ticket or Queue argument.
+Returns type of a ticket. Takes Ticket, Lifecycle or Queue as an argument.
Both arguments could be objects or IDs, however, name of a queue
works too for Queue argument. If the queue argument is defined then
the ticket is ignored even if it's defined too.
@@ -167,22 +178,31 @@ the ticket is ignored even if it's defined too.
=cut
sub TicketType {
- my %arg = ( Queue => undef, Ticket => undef, @_);
+ my %arg = ( Lifecycle => undef, Queue => undef, Ticket => undef, @_);
+ if ( defined $arg{'Lifecycle'}) {
+ return $TYPE{$arg{'Lifecycle'}};
+ }
if ( defined $arg{'Ticket'} && !defined $arg{'Queue'} ) {
my $obj = RT::Ticket->new( RT->SystemUser );
$obj->Load( ref $arg{'Ticket'} ? $arg{'Ticket'}->id : $arg{'Ticket'} );
- $arg{'Queue'} = $obj->QueueObj->Name if $obj->id;
+ return $TYPE{ $obj->QueueObj->Lifecycle } if $obj->id;
}
return undef unless defined $arg{'Queue'};
- return $TYPE{ lc $arg{'Queue'} } if !ref $arg{'Queue'} && $arg{'Queue'} !~ /^\d+$/;
-
my $obj = RT::Queue->new( RT->SystemUser );
- $obj->Load( ref $arg{'Queue'}? $arg{'Queue'}->id : $arg{'Queue'} );
- return $TYPE{ lc $obj->Name } if $obj->id;
+ if (ref $arg{'Queue'}) {
+ $obj->Load($arg{'Queue'}->id);
+ }
+ elsif ($arg{'Queue'} =~/^\d+$/) {
+ $obj->Load($arg{'Queue'});
+ } else {
+ $obj->LoadByCols(Name => $arg{'Queue'});
+ }
- return;
+ return undef unless ($obj->id);
+
+ return $TYPE{ $obj->Lifecycle };
}
=head2 Statuses
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list