[Rt-commit] rt branch, 4.2/time-worked-txn-display, created. rt-4.1.6-387-g23e3058
Thomas Sibley
trs at bestpractical.com
Mon Apr 1 13:39:11 EDT 2013
The branch, 4.2/time-worked-txn-display has been created
at 23e30580a4066ab511a0c06816c09942ce0afc4b (commit)
- Log -----------------------------------------------------------------
commit 23e30580a4066ab511a0c06816c09942ce0afc4b
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Mar 29 15:48:55 2013 -0700
Calculate the duration of time worked for history display
Showing a useful duration is easier to quickly read and understand than
showing the before and after value in minutes. Why subtract when the
computer can!
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 13635ec..829ef27 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -997,6 +997,20 @@ sub _FormatUser {
($self->OldValue? "'".$self->OldValue ."'" : $self->loc("(no value)")) , "'". $self->NewValue."'" );
}
},
+ "Set-TimeWorked" => sub {
+ my $self = shift;
+ my $old = $self->OldValue || 0;
+ my $new = $self->NewValue || 0;
+ my $duration = $new - $old;
+ if ($duration < 0) {
+ return ("Adjusted time worked by [quant,_1,minute,minutes]", $duration);
+ }
+ elsif ($duration < 60) {
+ return ("Worked [quant,_1,minute,minutes]", $duration);
+ } else {
+ return ("Worked [quant,_1,hour,hours] ([numf,_2] minutes)", sprintf("%.1f", $duration / 60), $duration);
+ }
+ },
PurgeTransaction => sub {
my $self = shift;
return ("Transaction [_1] purged", $self->Data); #loc
diff --git a/t/web/basic.t b/t/web/basic.t
index cea0d07..0942be3 100644
--- a/t/web/basic.t
+++ b/t/web/basic.t
@@ -3,7 +3,7 @@ use strict;
use warnings;
use Encode;
-use RT::Test tests => 23;
+use RT::Test tests => 24;
my ($baseurl, $agent) = RT::Test->started_ok;
@@ -72,7 +72,8 @@ my $url = $agent->rt_base_url;
fields => { TimeWorked => 5, 'TimeWorked-TimeUnits' => "hours" }
);
- $agent->content_contains("to '300'", "5 hours is 300 minutes");
+ $agent->content_contains("5 hours", "5 hours is displayed");
+ $agent->content_contains("300 min", "but minutes is also");
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list