# HG changeset patch # User cin # Date 1441642701 -10800 # Node ID 4eb9fdf4efa963f17eb47dcf613365782902fb57 # Parent 14a9663692787fb734cec3af07c6aa09969dbcfa refactoring, non-working bookings diff -r 14a966369278 -r 4eb9fdf4efa9 bug-list.xsl --- a/bug-list.xsl Mon Sep 07 01:37:11 2015 +0300 +++ b/bug-list.xsl Mon Sep 07 19:18:21 2015 +0300 @@ -1,7 +1,8 @@ + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="exsl date"> @@ -113,6 +114,8 @@ + @@ -143,15 +146,12 @@ + - - - - + @@ -162,6 +162,7 @@ + @@ -170,48 +171,12 @@ - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - + @@ -222,9 +187,11 @@ + - + + @@ -237,40 +204,84 @@ + + + + - + + + + + - + + + + - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + @@ -282,13 +293,104 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - diff -r 14a966369278 -r 4eb9fdf4efa9 lib/Benzin/Bugzilla/Bug.pm --- a/lib/Benzin/Bugzilla/Bug.pm Mon Sep 07 01:37:11 2015 +0300 +++ b/lib/Benzin/Bugzilla/Bug.pm Mon Sep 07 19:18:21 2015 +0300 @@ -45,9 +45,7 @@ use constant { BUG_FIELDS => \@fields }; -use IMPL::declare { - base => [ 'IMPL::Object::Fields' => undef ] -}; +use IMPL::declare { base => [ 'IMPL::Object::Fields' => undef ] }; use fields @fields; sub CTOR { @@ -67,14 +65,25 @@ sub GetTimeReports { my SELF $this = shift; my $resolution = shift || 0.25; + my $span = $resolution * 60; my @bookings; my $actual = 0; for my $history ( @{ $this->{history} || [] } ) { - my $who = $history->{who}; + my $who = $history->{who}; my $when = $history->{when}; 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' ) { @@ -86,11 +95,10 @@ if ($dt) { push @bookings, { - end => $who, - when => $when->iso8601(), + who => $who, + end => $when, work_time => $dt, start => $when->clone()->subtract( hours => $dt ) - ->iso8601() }; $actual += $dt; } @@ -99,10 +107,12 @@ } } + my $remaining = coarsen( $this->{remaining_time}, $resolution ); return { - reports => \@bookings, + report => \@bookings, actual => $actual, - remaining => coarsen( $this->{remaining_time}, $resolution ) + remaining => $remaining, + estimated => $actual + $remaining }; } diff -r 14a966369278 -r 4eb9fdf4efa9 lib/Benzin/Bugzilla/XmlWriter.pm --- a/lib/Benzin/Bugzilla/XmlWriter.pm Mon Sep 07 01:37:11 2015 +0300 +++ b/lib/Benzin/Bugzilla/XmlWriter.pm Mon Sep 07 19:18:21 2015 +0300 @@ -1,25 +1,28 @@ package Benzin::Bugzilla::XmlWriter; our %Transform = ( - 'Benzin::Bugzilla::Bug' => 'WriteBug', + 'Benzin::Bugzilla::Bug' => 'WriteBug', 'Benzin::Bugzilla::BugComment' => 'WriteBugComment', - 'HASH' => 'WriteHash', - -plain => 'WriteValue', - -default => 'WriteValue' + 'HASH' => 'WriteHash', + 'DateTime' => 'WriteTJ3DateTime', + -plain => 'WriteValue', + -default => 'WriteValue' ); use IMPL::Const qw(:prop); use IMPL::declare { require => { - XMLWriter => 'XML::Writer', - Bug => 'Benzin::Bugzilla::Bug', - BugComment => 'Benzin::Bugzilla::BugComment' + XMLWriter => 'XML::Writer', + Bug => 'Benzin::Bugzilla::Bug', + BugComment => 'Benzin::Bugzilla::BugComment', }, base => [ 'IMPL::Transform' => sub { %Transform } ], props => [ - _writer => PROP_RW + _writer => PROP_RW, + timereports => PROP_RW, + timeresolution => PROP_RW ] }; @@ -27,44 +30,45 @@ sub CTOR { my SELF $this = shift; - - $this->_writer(XMLWriter->new(@_)); + + $this->_writer( XMLWriter->new(@_) ); } sub WriteBugList { my SELF $this = shift; my $bugs = shift || []; my $writer = $this->_writer; - - + $writer->xmlDecl("UTF-8"); $writer->startTag("bugzilla"); - - + foreach my $bug (@$bugs) { $writer->startTag("bug"); $this->WriteBug($bug); $writer->endTag(); } - + $writer->endTag(); - + } sub WriteBug { my SELF $this = shift; - my $value = shift; + my $value = shift; my $writer = $this->_writer; foreach my $field ( @{ Bug->BUG_FIELDS } ) { next unless $value->{$field}; $this->WriteElement( $field, $value->{$field} ); } + $this->WriteElement( 'time', + $value->GetTimeReports( $this->timeresolution ) ) + if $this->timereports; } sub WriteBugComment { my SELF $this = shift; - my $value = shift; + my $value = shift; my $writer = $this->_writer; foreach my $field ( @{ BugComment->COMMENT_FIELDS } ) { @@ -76,9 +80,9 @@ sub WriteHash { my SELF $this = shift; my $value = shift; - - while(my ($k,$v) = each %$value) { - $this->WriteElement($k,$v); + + while ( my ( $k, $v ) = each %$value ) { + $this->WriteElement( $k, $v ); } } @@ -95,7 +99,7 @@ foreach my $v (@values) { $writer->startTag($name); - $this->Transform( $v ); + $this->Transform($v); $writer->endTag; } } @@ -103,8 +107,15 @@ sub WriteValue { my SELF $this = shift; my $value = shift; - + $this->_writer->characters($value) if defined $value; } +sub WriteTJ3DateTime { + my SELF $this = shift; + my $value = shift; + + $this->_writer->characters($value->strftime('%F-%T')) if defined $value; +} + 1; diff -r 14a966369278 -r 4eb9fdf4efa9 translate.pl --- a/translate.pl Mon Sep 07 01:37:11 2015 +0300 +++ b/translate.pl Mon Sep 07 19:18:21 2015 +0300 @@ -26,6 +26,7 @@ my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ], + #[ 'cat' ], '', \*STDOUT ) or die "failed to create pipe: $!"; @@ -33,6 +34,8 @@ binmode *HIN, ":encoding(utf-8)"; my $writer = BugWriter->new( OUTPUT => *HIN, DATA_INDENT => 2, DATA_MODE => 'on' ); +$writer->timereports('on'); +$writer->timeresolution(0.25); eval { my %visited;