Mercurial > pub > buggler
diff lib/Benzin/Bugzilla/Bug.pm @ 12:52b34ea50eff default tip
sync: work time projection doesn't seem to be working anyway
author | cin |
---|---|
date | Sun, 13 Sep 2015 19:37:16 +0300 |
parents | 4eb9fdf4efa9 |
children |
line wrap: on
line diff
--- a/lib/Benzin/Bugzilla/Bug.pm Mon Sep 07 19:18:21 2015 +0300 +++ b/lib/Benzin/Bugzilla/Bug.pm Sun Sep 13 19:37:16 2015 +0300 @@ -45,6 +45,7 @@ use constant { BUG_FIELDS => \@fields }; +use IMPL::lang qw(coarsen coarsen_dt); use IMPL::declare { base => [ 'IMPL::Object::Fields' => undef ] }; use fields @fields; @@ -64,41 +65,31 @@ # } sub GetTimeReports { my SELF $this = shift; - my $resolution = shift || 0.25; - my $span = $resolution * 60; + my $resolution = + DateTime::Duration->new( %{ shift() || { minutes => 15 } } ); my @bookings; my $actual = 0; for my $history ( @{ $this->{history} || [] } ) { my $who = $history->{who}; - my $when = $history->{when}; + my $when = coarsen_dt( $history->{when}, $resolution ); my $changes = $history->{changes}; - - my $minutes = coarsen( $when->minute(), $span ); - - if ($minutes >= 60 ) { - $when->add(hours => 1); - $minutes -= 60; - } - $when->set_second(0); - $when->set_minute($minutes); - for my $change ( @{ $changes || [] } ) { if ( $change->{field_name} eq 'work_time' ) { my $prev = $change->{removed} || 0; my $value = $change->{added} || 0; if ( looks_like_number($prev) and looks_like_number($value) ) { - my $dt = coarsen( $value - $prev, $resolution ); + my $dt = + coarsen( $value - $prev, $resolution->in_units('hours') ); if ($dt) { push @bookings, { who => $who, - end => $when, - work_time => $dt, - start => $when->clone()->subtract( hours => $dt ) + when => $when, + work_time => $dt }; $actual += $dt; } @@ -107,7 +98,7 @@ } } - my $remaining = coarsen( $this->{remaining_time}, $resolution ); + my $remaining = coarsen( $this->{remaining_time}, $resolution->in_units('hours') ); return { report => \@bookings, actual => $actual, @@ -116,9 +107,4 @@ }; } -sub coarsen { - my ( $value, $resolution ) = @_; - return $resolution ? ceil( $value / $resolution ) * $resolution : $value; -} - 1;