Hello :
Customer needs : LinearEscalate + still seing prio (dec/incr)easing after
a ticket is due.
Solution a little patch on LinearEscalate (as shiped in rt3.8.2).
If it can help.
Friendly
--
Julien Tayon // digital craftsman // making things simpler (when possible)
Clothes make the man. Naked people have little or no influence on society.
-- Mark Twain
--
Julien Tayon // digital craftsman // making things simpler (when possible)
<evilkalla> heh, I never took a coding class
<evilkalla> or a graphics class
<evilkalla> or a software design class
<vegan> and it shows :P
--- LinearEscalate.pm 2009-04-03 13:18:40.000000000 +0200
+++ IncreasePriority.pm 2009-04-03 14:59:09.000000000 +0200
@@ -48,7 +48,7 @@
=head1 NAME
-RT::Action::LinearEscalate - will move a ticket's priority toward its final priority.
+RT::Action::IncreasePriority - will move a ticket's priority toward its final priority and go on.
=head1 This vs. RT::Action::EscalatePriority
@@ -63,7 +63,7 @@
default due date. For example a week then priorities of your tickets will
escalate linearly during the week from intial value towards final.
-=head1 This vs. LinearEscalate from the CPAN
+=head1 This vs. IncreasePriority from the CPAN
This action is an integration of the module from the CPAN into RT's core
that's happened in RT 3.8. If you're upgrading from 3.6 and have been using
@@ -75,7 +75,7 @@
=head1 DESCRIPTION
-LinearEscalate is a ScripAction that will move a ticket's priority
+IncreasePriority is a ScripAction that will move a ticket's priority
from its initial priority to its final priority linearly as
the ticket approaches its due date.
@@ -89,7 +89,7 @@
rt-crontool --search RT::Search::FromSQL --search-arg \
"(Status='new' OR Status='open' OR Status = 'stalled')" \
- --action RT::Action::LinearEscalate
+ --action RT::Action::IncreasePriority
The Starts date is associated with intial ticket's priority or
the Created field if the former is not set. End of interval is
@@ -102,7 +102,7 @@
action should handle correctly situations when initial priority
is greater than final.
-LinearEscalate's behavior can be controlled by two options:
+IncreasePriority's behavior can be controlled by two options:
=over 4
@@ -125,7 +125,7 @@
rt-crontool --search RT::Search::FromSQL --search-arg \
"(Status='new' OR Status='open' OR Status = 'stalled')" \
- --action RT::Action::LinearEscalate \
+ --action RT::Action::IncreasePriority \
--action-arg "RecordTransaction: 1"
This ScripAction uses RT's internal _Set or __Set calls to set ticket
@@ -134,7 +134,7 @@
=cut
-package RT::Action::LinearEscalate;
+package RT::Action::IncreasePriority;
use strict;
use warnings;
@@ -154,26 +154,32 @@
sub Prepare {
my $self = shift;
-
+use Data::Dumper;
my $ticket = $self->TicketObj;
-
+ my $due_obj = $ticket->DueObj;
my $due = $ticket->DueObj->Unix;
+ my $starts = $ticket->StartsObj->Unix;
+ $starts = $ticket->CreatedObj->Unix unless ( $starts > 0 ) ;
+ my $now = time;
unless ( $due > 0 ) {
- $RT::Logger->debug('Due is not set. Not escalating.');
- return 1;
+ $RT::Logger->debug('Due is not set. Not escalating. ' );
+ return 1;
+ }
+ if ( $due < $starts) {
+ $RT::Logger->debug("due < starts Fumage de moquette Starts " . $ticket->Starts . " Due " . $ticket->Due );
+ return 1;
}
-
my $priority_range = $ticket->FinalPriority - $ticket->InitialPriority;
- unless ( $priority_range ) {
+ if ( $priority_range == 0 && $now < $due ) {
$RT::Logger->debug('Final and Initial priorities are equal. Not escalating.');
return 1;
}
- if ( $ticket->Priority >= $ticket->FinalPriority && $priority_range > 0 ) {
+ if ( $ticket->Priority >= $ticket->FinalPriority && $priority_range > 0 && $now < $due ) {
$RT::Logger->debug('Current priority is greater than final. Not escalating.');
return 1;
}
- elsif ( $ticket->Priority <= $ticket->FinalPriority && $priority_range < 0 ) {
+ elsif ( $ticket->Priority <= $ticket->FinalPriority && $priority_range < 0 && $now < $due ) {
$RT::Logger->debug('Current priority is lower than final. Not escalating.');
return 1;
}
@@ -183,9 +189,6 @@
# now we know we have a due date. for every day that passes,
# increment priority according to the formula
- my $starts = $ticket->StartsObj->Unix;
- $starts = $ticket->CreatedObj->Unix unless $starts > 0;
- my $now = time;
# do nothing if we didn't reach starts or created date
if ( $starts > $now ) {
@@ -195,18 +198,18 @@
$due = $starts + 1 if $due <= $starts; # +1 to avoid div by zero
- my $percent_complete = ($now-$starts)/($due - $starts);
+ my $ratio_complete = ($now-$starts)/($due - $starts);
- my $new_priority = int($percent_complete * $priority_range) + $ticket->InitialPriority;
- $new_priority = $ticket->FinalPriority if $new_priority > $ticket->FinalPriority;
+ my $new_priority = int($ratio_complete * $priority_range) + $ticket->InitialPriority;
+ $new_priority = $ticket->FinalPriority if ( $new_priority > $ticket->FinalPriority && $now < $due);
+#print STDERR " Nouvelle prio NP $new_priority RC $ratio_complete IP " . $ticket->InitialPriority . " FP " . $ticket->FinalPriority . " ST ". $ticket->Starts . " DUE " . $ticket->Due . " ID " . $ticket->Id." \n";
+# increment des overdue
$self->{'new_priority'} = $new_priority;
-
return 1;
}
sub Commit {
my $self = shift;
-
my $new_value = $self->{'new_priority'};
return 1 unless defined $new_value;
@@ -263,10 +266,10 @@
return 1;
}
-eval "require RT::Action::LinearEscalate_Vendor";
-die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Action/LinearEscalate_Vendor.pm} );
-eval "require RT::Action::LinearEscalate_Local";
-die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Action/LinearEscalate_Local.pm} );
+eval "require RT::Action::IncreasePriority_Vendor";
+die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Action/IncreasePriority_Vendor.pm} );
+eval "require RT::Action::IncreasePriority_Local";
+die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Action/IncreasePriority_Local.pm} );
1;
@@ -276,4 +279,6 @@
Ruslan Zakirov E<lt>[email protected]<gt>
+Julien Tayon E<lt>[email protected]<gt>
+
=cut_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
Community help: http://wiki.bestpractical.com
Commercial support: [email protected]
Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com