Mercurial > pub > buggler
diff lib/Benzin/Bugzilla/XmlRpcClient.pm @ 9:cc7244ab1b9f
implemented time reports on bugs
author | cin |
---|---|
date | Sat, 05 Sep 2015 22:01:12 +0300 |
parents | 29309bc8d932 |
children | 14a966369278 |
line wrap: on
line diff
--- a/lib/Benzin/Bugzilla/XmlRpcClient.pm Fri Sep 04 19:42:15 2015 +0300 +++ b/lib/Benzin/Bugzilla/XmlRpcClient.pm Sat Sep 05 22:01:12 2015 +0300 @@ -5,14 +5,16 @@ use XMLRPC::Lite; use YAML::XS qw(Dump); -use IMPL::require { - Bug => 'Benzin::Bugzilla::Bug' +use IMPL::declare { + require => { + Bug => 'Benzin::Bugzilla::Bug', + BugComment => 'Benzin::Bugzilla::BugComment' + }, + base => { 'IMPL::Object::Fields' => undef } }; use fields qw(url apikey); -use constant { SELF => __PACKAGE__ }; - sub new { my $class = shift; $class = ref $class || $class; @@ -34,21 +36,47 @@ sub GetBugs { my SELF $this = shift; - return [map Bug->new($_), @{$this->_CallService( 'Bug.get', shift )->{bugs} || [] }]; + return [ + map Bug->new($_), + @{ $this->_CallService( 'Bug.get', shift )->{bugs} || [] } + ]; } -sub FillBugComments { +sub PopulateBugsWithComments { my SELF $this = shift; my $bugs = shift || []; if ( my @ids = map $_->{id}, @$bugs ) { - my $comments = $this->_CallService( 'Bug.comments', { ids => \@ids } ); - + my $resp = $this->_CallService( 'Bug.comments', { ids => \@ids } ); + for my Bug $bug (@$bugs) { - map @{$comments->{$bug->{id}}->{comments} || [] }; + $bug->{comments} = [ + map BugComment->new($_), + @{ $resp->{bugs}{ $bug->{id} }->{comments} || [] } + ]; } } + return; +} + +sub PopulateBugsHistory { + my SELF $this = shift; + + my %bugs = map { $_->{id}, $_ } @{ shift || [] }; + + if ( keys %bugs ) { + + my $resp = + $this->_CallService( 'Bug.history', { ids => [ keys %bugs ] } )->{bugs}; + + for my $data (@$resp) { + my Bug $bug = $bugs{$data->{id}}; + + $bug->{history} = $data->{history}; + } + } + return; } sub _CallService {