Mercurial > pub > buggler
comparison 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 |
comparison
equal
deleted
inserted
replaced
8:ff9c0c788382 | 9:cc7244ab1b9f |
---|---|
3 | 3 |
4 use LWP::UserAgent; | 4 use LWP::UserAgent; |
5 use XMLRPC::Lite; | 5 use XMLRPC::Lite; |
6 use YAML::XS qw(Dump); | 6 use YAML::XS qw(Dump); |
7 | 7 |
8 use IMPL::require { | 8 use IMPL::declare { |
9 Bug => 'Benzin::Bugzilla::Bug' | 9 require => { |
10 Bug => 'Benzin::Bugzilla::Bug', | |
11 BugComment => 'Benzin::Bugzilla::BugComment' | |
12 }, | |
13 base => { 'IMPL::Object::Fields' => undef } | |
10 }; | 14 }; |
11 | 15 |
12 use fields qw(url apikey); | 16 use fields qw(url apikey); |
13 | |
14 use constant { SELF => __PACKAGE__ }; | |
15 | 17 |
16 sub new { | 18 sub new { |
17 my $class = shift; | 19 my $class = shift; |
18 $class = ref $class || $class; | 20 $class = ref $class || $class; |
19 | 21 |
32 } | 34 } |
33 | 35 |
34 sub GetBugs { | 36 sub GetBugs { |
35 my SELF $this = shift; | 37 my SELF $this = shift; |
36 | 38 |
37 return [map Bug->new($_), @{$this->_CallService( 'Bug.get', shift )->{bugs} || [] }]; | 39 return [ |
40 map Bug->new($_), | |
41 @{ $this->_CallService( 'Bug.get', shift )->{bugs} || [] } | |
42 ]; | |
38 } | 43 } |
39 | 44 |
40 sub FillBugComments { | 45 sub PopulateBugsWithComments { |
41 my SELF $this = shift; | 46 my SELF $this = shift; |
42 my $bugs = shift || []; | 47 my $bugs = shift || []; |
43 | 48 |
44 if ( my @ids = map $_->{id}, @$bugs ) { | 49 if ( my @ids = map $_->{id}, @$bugs ) { |
45 | 50 |
46 my $comments = $this->_CallService( 'Bug.comments', { ids => \@ids } ); | 51 my $resp = $this->_CallService( 'Bug.comments', { ids => \@ids } ); |
47 | 52 |
48 for my Bug $bug (@$bugs) { | 53 for my Bug $bug (@$bugs) { |
49 map @{$comments->{$bug->{id}}->{comments} || [] }; | 54 $bug->{comments} = [ |
55 map BugComment->new($_), | |
56 @{ $resp->{bugs}{ $bug->{id} }->{comments} || [] } | |
57 ]; | |
50 } | 58 } |
51 } | 59 } |
60 return; | |
61 } | |
62 | |
63 sub PopulateBugsHistory { | |
64 my SELF $this = shift; | |
65 | |
66 my %bugs = map { $_->{id}, $_ } @{ shift || [] }; | |
67 | |
68 if ( keys %bugs ) { | |
69 | |
70 my $resp = | |
71 $this->_CallService( 'Bug.history', { ids => [ keys %bugs ] } )->{bugs}; | |
72 | |
73 for my $data (@$resp) { | |
74 my Bug $bug = $bugs{$data->{id}}; | |
75 | |
76 $bug->{history} = $data->{history}; | |
77 } | |
78 } | |
79 return; | |
52 } | 80 } |
53 | 81 |
54 sub _CallService { | 82 sub _CallService { |
55 my SELF $this = shift; | 83 my SELF $this = shift; |
56 my ( $method, $params ) = @_; | 84 my ( $method, $params ) = @_; |