Mercurial > pub > buggler
diff translate.pl @ 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/translate.pl Fri Sep 04 19:42:15 2015 +0300 +++ b/translate.pl Sat Sep 05 22:01:12 2015 +0300 @@ -1,8 +1,10 @@ #!/usr/bin/perl -w -use JSON; +use IMPL::require { + BzClient => 'Benzin::Bugzilla::XmlRpcClient', + Bug => 'Benzin::Bugzilla::Bug' +}; use YAML::XS qw(LoadFile Dump); -use URI; use XML::Writer; use IPC::Run qw(start finish); @@ -20,138 +22,50 @@ $config->{bugzilla}{url} .= "/"; } -my $bz = BzRest->new( +my $bz = BzClient->new( url => $config->{bugzilla}{url}, apikey => $config->{bugzilla}{apikey} ); -my @fields = qw( - id - summary - creation_time - last_change_time - creator - assigned_to - - status - resolution - - priority - severity - url - - blocks - depends_on - cc - - component - product - classification - version - - actual_time - estimated_time - remainig_time - deadline -); - -my %fieldsMap = ( - summary => 'short_desc', - id => 'bug_id', - creator => 'reporter', - status => 'bug_status', - severity => 'bug_severity', - blocks => 'blocked', - depends_on => 'dependson', - creation_time => 'creation_ts', - last_change_time => 'delta_ts' -); - local (*HIN); my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ], '<pipe', \*HIN, '>', \*STDOUT ) or die "failed to create pipe: $!"; -my $writer = XML::Writer->new( OUTPUT => \*HIN, ENCODING => 'utf-8' ); - -$writer->xmlDecl("UTF-8"); -$writer->startTag("bugzilla"); - -my %visited; -my @queue = (283); +eval { + my %visited; + my @queue = (283); + my @fetched; -while (@queue) { - @queue = grep not( $visited{$_}++ ), @queue; + while (@queue) { + @queue = grep not( $visited{$_}++ ), @queue; - last unless @queue; + last unless @queue; - print "#Fetching: ", join( ', ', @queue ), "\n"; - - my $bugs = $bz->GetBugs( { ids => \@queue } ); + print "#Fetching: ", join( ', ', @queue ), "\n"; - @queue = (); - - foreach my $bug (@$bugs) { + my $bugs = $bz->GetBugs( { ids => \@queue } ); + @queue = (); - push @queue, @{ $bug->{depends_on} } - if ( $bug->{depends_on} ); - - $writer->startTag("bug"); - foreach my $field (@fields) { - next unless $bug->{$field}; + foreach my $bug (@$bugs) { - my $tagName = $fieldsMap{$field} || $field; - my @values = - ref( $bug->{$field} ) - && ref( $bug->{$field} ) eq 'ARRAY' - ? @{ $bug->{$field} } - : $bug->{$field}; + push @queue, @{ $bug->{depends_on} } + if ( $bug->{depends_on} ); + push @fetched, $bug; + } + } + print Dump( \@fetched ); - foreach my $v (@values) { - $writer->dataElement( $tagName, $v ); - } - } - $writer->endTag(); + $bz->PopulateBugsWithComments( \@fetched ); + $bz->PopulateBugsHistory( \@fetched ); - } -} + print Dump( [ map $_->GetTimeReports(0.25), @fetched ] ); -$writer->endTag(); +}; +warn Dump($@) and die $@ if $@; close HIN; finish($proc); -package BzRest; - - - -__END__ - -=pod - -=head1 NAME - -C<translate.pl> - translates bugzilla xml buglist to TaskJuggler format - -=head1 METHODS - -=head2 xalan(%args) - -=over - -=item * -IN - -Input file - -=item * -OUT - -Output file - -=item * -XSL - -XSLT file - -=back - -=cut +1;