annotate translate.pl @ 9:cc7244ab1b9f

implemented time reports on bugs
author cin
date Sat, 05 Sep 2015 22:01:12 +0300
parents 29309bc8d932
children 14a966369278
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8cae44c166d3 initial xslt and sample xml
cin
parents:
diff changeset
1 #!/usr/bin/perl -w
8cae44c166d3 initial xslt and sample xml
cin
parents:
diff changeset
2
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
3 use IMPL::require {
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
4 BzClient => 'Benzin::Bugzilla::XmlRpcClient',
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
5 Bug => 'Benzin::Bugzilla::Bug'
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
6 };
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
7 use YAML::XS qw(LoadFile Dump);
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
8 use XML::Writer;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
9 use IPC::Run qw(start finish);
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
10
1
d1400de5832b improved xsl
cin
parents: 0
diff changeset
11 our @ClassPath = qw(
d1400de5832b improved xsl
cin
parents: 0
diff changeset
12 /usr/share/java/xalan-j2-serializer.jar
d1400de5832b improved xsl
cin
parents: 0
diff changeset
13 /usr/share/java/xalan-j2.jar
d1400de5832b improved xsl
cin
parents: 0
diff changeset
14 /usr/share/java/xerces-j2.jar
d1400de5832b improved xsl
cin
parents: 0
diff changeset
15 /usr/share/java/xml-commons-resolver.jar
d1400de5832b improved xsl
cin
parents: 0
diff changeset
16 .
d1400de5832b improved xsl
cin
parents: 0
diff changeset
17 );
d1400de5832b improved xsl
cin
parents: 0
diff changeset
18
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
19 my $config = LoadFile("config.yaml");
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
20
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
21 if ( !( $config->{bugzilla}{url} =~ /\/$/ ) ) {
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
22 $config->{bugzilla}{url} .= "/";
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
23 }
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
24
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
25 my $bz = BzClient->new(
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
26 url => $config->{bugzilla}{url},
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
27 apikey => $config->{bugzilla}{apikey}
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
28 );
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
29
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
30 local (*HIN);
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
31
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
32 my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ],
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
33 '<pipe', \*HIN, '>', \*STDOUT )
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
34 or die "failed to create pipe: $!";
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
35
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
36 eval {
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
37 my %visited;
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
38 my @queue = (283);
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
39 my @fetched;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
40
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
41 while (@queue) {
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
42 @queue = grep not( $visited{$_}++ ), @queue;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
43
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
44 last unless @queue;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
45
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
46 print "#Fetching: ", join( ', ', @queue ), "\n";
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
47
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
48 my $bugs = $bz->GetBugs( { ids => \@queue } );
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
49 @queue = ();
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
50
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
51 foreach my $bug (@$bugs) {
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
52
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
53 push @queue, @{ $bug->{depends_on} }
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
54 if ( $bug->{depends_on} );
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
55 push @fetched, $bug;
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
56 }
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
57 }
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
58 print Dump( \@fetched );
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
59
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
60 $bz->PopulateBugsWithComments( \@fetched );
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
61 $bz->PopulateBugsHistory( \@fetched );
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
62
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
63 print Dump( [ map $_->GetTimeReports(0.25), @fetched ] );
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
64
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
65 };
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
66 warn Dump($@) and die $@ if $@;
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
67
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
68 close HIN;
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
69 finish($proc);
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
70
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
71 1;