Mercurial > pub > buggler
annotate 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 |
| rev | line source |
|---|---|
| 7 | 1 package Benzin::Bugzilla::Bug; |
| 2 use strict; | |
| 9 | 3 use POSIX; |
| 4 use Scalar::Util qw(looks_like_number); | |
| 5 use DateTime; | |
| 7 | 6 |
| 9 | 7 my @fields; |
| 7 | 8 |
| 9 BEGIN { | |
| 9 | 10 @fields = qw( |
| 7 | 11 id |
| 12 summary | |
| 13 creation_time | |
| 14 last_change_time | |
| 15 creator | |
| 16 assigned_to | |
| 17 qa_contact | |
| 18 cc | |
| 19 | |
| 9 | 20 is_open |
| 7 | 21 status |
| 22 resolution | |
| 23 | |
| 24 priority | |
| 25 severity | |
| 26 url | |
| 27 | |
| 28 blocks | |
| 29 depends_on | |
| 30 | |
| 31 component | |
| 32 product | |
| 33 classification | |
| 34 version | |
| 35 | |
| 36 actual_time | |
| 37 estimated_time | |
| 38 remaining_time | |
| 39 deadline | |
| 9 | 40 |
| 7 | 41 comments |
| 9 | 42 history |
| 7 | 43 ); |
| 44 } | |
| 45 | |
| 9 | 46 use constant { BUG_FIELDS => \@fields }; |
| 7 | 47 |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
48 use IMPL::lang qw(coarsen coarsen_dt); |
| 11 | 49 use IMPL::declare { base => [ 'IMPL::Object::Fields' => undef ] }; |
| 9 | 50 use fields @fields; |
| 51 | |
| 7 | 52 sub CTOR { |
| 53 my SELF $this = shift; | |
| 9 | 54 my $data = shift; |
| 55 $this->{$_} = $data->{$_} | |
| 56 foreach grep exists $data->{$_}, @{ SELF->BUG_FIELDS }; | |
| 7 | 57 } |
| 58 | |
| 9 | 59 # returns { |
| 60 # reports => [ | |
|
10
14a966369278
working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents:
9
diff
changeset
|
61 # { who => email:string, start => work-start-date-time:DateTime, end => report-date-time:DateTime, work_time => hours:double } |
| 9 | 62 # ], |
| 63 # actual => hours | |
| 64 # remaining => hours | |
| 65 # } | |
| 66 sub GetTimeReports { | |
| 7 | 67 my SELF $this = shift; |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
68 my $resolution = |
|
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
69 DateTime::Duration->new( %{ shift() || { minutes => 15 } } ); |
| 9 | 70 |
| 71 my @bookings; | |
| 72 my $actual = 0; | |
| 73 | |
| 74 for my $history ( @{ $this->{history} || [] } ) { | |
| 11 | 75 my $who = $history->{who}; |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
76 my $when = coarsen_dt( $history->{when}, $resolution ); |
| 9 | 77 my $changes = $history->{changes}; |
| 78 | |
| 79 for my $change ( @{ $changes || [] } ) { | |
| 80 if ( $change->{field_name} eq 'work_time' ) { | |
| 81 my $prev = $change->{removed} || 0; | |
| 82 my $value = $change->{added} || 0; | |
| 83 if ( looks_like_number($prev) and looks_like_number($value) ) { | |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
84 my $dt = |
|
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
85 coarsen( $value - $prev, $resolution->in_units('hours') ); |
| 9 | 86 |
| 87 if ($dt) { | |
| 88 push @bookings, | |
| 89 { | |
| 11 | 90 who => $who, |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
91 when => $when, |
|
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
92 work_time => $dt |
| 9 | 93 }; |
| 94 $actual += $dt; | |
| 95 } | |
| 96 } | |
| 97 } | |
| 98 } | |
| 99 } | |
| 100 | |
|
12
52b34ea50eff
sync: work time projection doesn't seem to be working anyway
cin
parents:
11
diff
changeset
|
101 my $remaining = coarsen( $this->{remaining_time}, $resolution->in_units('hours') ); |
| 9 | 102 return { |
| 11 | 103 report => \@bookings, |
| 9 | 104 actual => $actual, |
| 11 | 105 remaining => $remaining, |
| 106 estimated => $actual + $remaining | |
| 9 | 107 }; |
| 7 | 108 } |
| 109 | |
|
10
14a966369278
working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents:
9
diff
changeset
|
110 1; |
