view 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 source

#!/usr/bin/perl -w

use IMPL::require {
	BzClient => 'Benzin::Bugzilla::XmlRpcClient',
	Bug      => 'Benzin::Bugzilla::Bug'
};
use YAML::XS qw(LoadFile Dump);
use XML::Writer;
use IPC::Run qw(start finish);

our @ClassPath = qw(
  /usr/share/java/xalan-j2-serializer.jar
  /usr/share/java/xalan-j2.jar
  /usr/share/java/xerces-j2.jar
  /usr/share/java/xml-commons-resolver.jar
  .
);

my $config = LoadFile("config.yaml");

if ( !( $config->{bugzilla}{url} =~ /\/$/ ) ) {
	$config->{bugzilla}{url} .= "/";
}

my $bz = BzClient->new(
	url    => $config->{bugzilla}{url},
	apikey => $config->{bugzilla}{apikey}
);

local (*HIN);

my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ],
	'<pipe', \*HIN, '>', \*STDOUT )
  or die "failed to create pipe: $!";

eval {
	my %visited;
	my @queue = (283);
	my @fetched;

	while (@queue) {
		@queue = grep not( $visited{$_}++ ), @queue;

		last unless @queue;

		print "#Fetching: ", join( ', ', @queue ), "\n";

		my $bugs = $bz->GetBugs( { ids => \@queue } );
		@queue = ();

		foreach my $bug (@$bugs) {

			push @queue, @{ $bug->{depends_on} }
			  if ( $bug->{depends_on} );
			push @fetched, $bug;
		}
	}
	print Dump( \@fetched );

	$bz->PopulateBugsWithComments( \@fetched );
	$bz->PopulateBugsHistory( \@fetched );

	print Dump( [ map $_->GetTimeReports(0.25), @fetched ] );

};
warn Dump($@) and die $@ if $@;

close HIN;
finish($proc);

1;