diff mbox series

[OSSTEST,40/60] sg-report-job-history: Refactor "ALL" handling

Message ID 20200814172205.9624-41-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series Speed up sg-report-job-history | expand

Commit Message

Ian Jackson Aug. 14, 2020, 5:21 p.m. UTC
* Make an explicit entry ALL in @branches, rather than implicitly
  processing ALL as well.

* Consequently, put explicit ALL entries in @tasks too, rather than
  putting in entries without a branch name.

* Pass ALL to processjobbranch rather than undef, and turn it into
  the internally-used undef at the start.

When used with --flight (findflight), this has no functional change.
When used with --job, ALL must now be included in the branch
list passed to --branches.  The only in-tree call is with --flight.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-job-history | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/sg-report-job-history b/sg-report-job-history
index 3b45992f..8932458e 100755
--- a/sg-report-job-history
+++ b/sg-report-job-history
@@ -72,7 +72,7 @@  sub findflight () {
         SELECT branch FROM flights WHERE flight=?
 END
     die "$flight ? @$branches ?" if @$branches!=1;
-    @branches= @$branches;
+    @branches= ('ALL', @$branches);
 
     my $selectq= db_prepare(<<END);
         SELECT job FROM jobs WHERE flight=? ORDER BY JOB
@@ -110,7 +110,10 @@  END
 }
 
 sub processjobbranch ($$$) {
-    my ($j,$bra,$html_file) = @_;
+    my ($j,$branch_or_all,$html_file) = @_;
+
+    my $bra = $branch_or_all;
+    undef $bra if $bra eq 'ALL';
 
     my $buildsq= db_prepare(<<END);
         SELECT * FROM runvars
@@ -294,14 +297,13 @@  END
 
 my @tasks;
 foreach my $j (@jobs) {
-    push @tasks, $j;
     push @tasks, "$j $_" foreach @branches;
 }
 
 parallel_by_fork('sg-report-job-history', $maxjobs, \@tasks, sub {
     my ($task) = @_;
     my ($job, $branch) = split / /, $task; # $branch might be undef
-    my $html_file = sprintf "history/%s/%s.html", $job, ($branch // 'ALL');
+    my $html_file = sprintf "history/%s/%s.html", $job, $branch;
     db_retry($dbh_tests, [], sub {
         processjobbranch($job, $branch, $html_file);
     });