]> xenbits.xensource.com Git - osstest.git/commitdiff
sg-report-job-history: Introduce use of cache, for hosts query
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 10 Aug 2020 15:52:01 +0000 (16:52 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Wed, 19 Aug 2020 10:41:18 +0000 (11:41 +0100)
* Set up the cache.
* Call the per-row setup hook.
* Cache the computation of $ri->{Hosts}.
* Call the per-row cache write hook.
* Finalise the cache.

Output is the same, but with cache information in the output html, and
faster.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
sg-report-job-history

index 5684ac02fd5db7e67c92f53b220009a8eb6b860c..9f1216a61feab104f3f5c697f56e908766d90650 100755 (executable)
@@ -121,6 +121,10 @@ sub processjobbranch ($$$) {
            AND name LIKE '%buildjob'
 END
 
+    cache_set_task_print("$j $branch_or_all");
+    cache_set_key_cols(qw(flight status)); # we process one job per process
+    cache_read_previous("$htmlout/$html_file");
+
     print DEBUG "processjobbranch('$j',", ($bra ? "'$bra'" : 'undef'), ")\n";
 
     my %rev_grid_col;
@@ -156,13 +160,17 @@ END
 END
 
     while (my $f= $flightsq->fetchrow_hashref()) {
+       cache_row_lookup_prep(\$f);
         my $ri= report_run_getinfo($f);
 
-       $ri->{Hosts} = { };
-       $hostq->execute($f->{flight}, $f->{job});
-       while (my ($hostvar,$host) = $hostq->fetchrow_array()) {
-           $ri->{Hosts}{$hostvar} = $host;
-       }
+       $ri->{Hosts} = cacheable_fn($f, 'h', sub {
+            my %hosts;
+           $hostq->execute($f->{flight}, $f->{job});
+           while (my ($hostvar,$host) = $hostq->fetchrow_array()) {
+               $hosts{$hostvar} = $host;
+           }
+           \%hosts;
+       });
 
         my %revisions;
         add_revisions(\%revisions, $f->{flight}, $f->{job}, '');
@@ -276,8 +284,10 @@ END
            print H "</td>";
        }
        print H "</tr>\n";
+       cache_write_entry(\*H, $r->{Flight});
        $alternate ^= 1;
     }
+    cache_finish(\*H, "");
     print H "</table></body></html>\n";
     H->error and die $!;
     close H or die $!;