diff mbox series

[OSSTEST,32/60] sg-report-job-history: Prep for fork: Move $revisionsq query

Message ID 20200814172205.9624-33-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
We will need to prepare this in add_revisions so that it works when we
do each (job,branch) in a different process.

It is OK that it is still global, becauswe we only call add_revisions
in the children.

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

Patch

diff --git a/sg-report-job-history b/sg-report-job-history
index 47fc7a62..424053f1 100755
--- a/sg-report-job-history
+++ b/sg-report-job-history
@@ -89,15 +89,16 @@  if (defined($flight)) {
     push @jobs, $job;
 }
 
-our $revisionsq= db_prepare(<<END);
+sub add_revisions ($$$$) {
+    my ($revmap, $flightnum, $j, $sfx) = @_;
+
+    our $revisionsq //= db_prepare(<<END);
         SELECT * FROM runvars
          WHERE flight=? AND job=?
            AND name LIKE 'built\\_revision\\_%'
 END
-# (We report on non-main-revision jobs just as for main-revision ones.)
+    # (We report on non-main-revision jobs just as for main-revision ones.)
 
-sub add_revisions ($$$$) {
-    my ($revmap, $flightnum, $j, $sfx) = @_;
     $revisionsq->execute($flightnum, $j);
     while (my $row= $revisionsq->fetchrow_hashref()) {
         my $n= $row->{name};