[Bps-public-commit] r19304 - RT-Extension-SLA/lib/RT/Action

ruz at bestpractical.com ruz at bestpractical.com
Mon Apr 20 13:56:12 EDT 2009


Author: ruz
Date: Mon Apr 20 13:56:12 2009
New Revision: 19304

Modified:
   RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm

Log:
* implement KeepInLoop feature

Modified: RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm
==============================================================================
--- RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm	(original)
+++ RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm	Mon Apr 20 13:56:12 2009
@@ -37,16 +37,17 @@
     my $txn = $self->TransactionObj;
     my $level = $ticket->FirstCustomFieldValue('SLA');
 
-    my $last_reply = $self->LastRequestorsEffectiveAct;
-    $RT::Logger->debug('Last effective requestors\' reply to ticket #'. $ticket->id .' is txn #'. $last_reply->id )
-        if $last_reply;
+    my ($last_reply, $is_requestor) = $self->LastEffectiveAct;
+    $RT::Logger->debug(
+        'Last effective '. ($is_requestor? '':'non-') .'requestors\' reply'
+        .' to ticket #'. $ticket->id .' is txn #'. $last_reply->id
+    );
 
-    my $response_due;
-    $response_due = $self->Due(
+    my $response_due = $self->Due(
         Level => $level,
-        Type => 'Response',
+        Type => $is_requestor? 'Response': 'KeepInLoop',
         Time => $last_reply->CreatedObj->Unix,
-    ) if $last_reply;
+    );
 
     my $resolve_due = $self->Due(
         Level => $level,
@@ -74,7 +75,7 @@
     return $self->TicketObj->Requestors->HasMemberRecursively( $actor )? 1 : 0;
 }
 
-sub LastRequestorsEffectiveAct {
+sub LastEffectiveAct {
     my $self = shift;
 
     my $txns = $self->TicketObj->Transactions;
@@ -87,10 +88,13 @@
 
     my $res;
     while ( my $txn = $txns->Next ) {
-        return $res unless $self->IsRequestorsAct( $txn );
+        unless ( $self->IsRequestorsAct( $txn ) ) {
+            last if $res;
+            return ($txn);
+        }
         $res = $txn;
     }
-    return $res;
+    return ($res, 'requestor');
 }
 
 1;



More information about the Bps-public-commit mailing list