]> xenbits.xensource.com Git - osstest.git/commitdiff
sg-report-flight: Refactor runvar access
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 27 Aug 2020 18:11:37 +0000 (19:11 +0100)
committerIan Jackson <iwj@xenproject.org>
Wed, 7 Oct 2020 17:39:48 +0000 (18:39 +0100)
Collect the runvars query into local perl variables.  This will allow
us to reuse the information without going back to the db.

No functional change.

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

index 0783458182ba6818321a783e09470a448b05de4b..281361c0d763f603ba337ae5f2b597f20bed08d6 100755 (executable)
@@ -1142,6 +1142,16 @@ END
     my $ji = $htmlout_jobq->fetchrow_hashref();
     die unless $ji;
 
+    my $varsq= db_prepare(<<END);
+        SELECT name, val, synth FROM runvars
+                WHERE flight=? AND job=?
+             ORDER BY synth, name
+END
+    $varsq->execute($fi->{Flight}, $job);
+    my $runvar_table = $varsq->fetchall_arrayref({});
+    my %runvar_map;
+    $runvar_map{$_->{name}} = $_ foreach @$runvar_table;
+
     print H <<END;
 <html><head><title>$title</title><head>
 <body>
@@ -1244,14 +1254,8 @@ END
 <h2>Test control variables</h2>
 <table rules=all><tr><th>Name</th><th>Value</th><th>Source</th></tr>
 END
-    my $varsq= db_prepare(<<END);
-        SELECT name, val, synth FROM runvars
-                WHERE flight=? AND job=?
-             ORDER BY synth, name
-END
-    $varsq->execute($fi->{Flight}, $job);
-    while (my $varrow= $varsq->fetchrow_arrayref()) {
-        my ($vn,$vv,$synth) = (@$varrow);
+    foreach my $varrow (@$runvar_table) {
+        my ($vn,$vv,$synth) = (@$varrow{qw(name val synth)});
         print H "<tr><th>".encode_entities($vn)."</th>";
         print H "<td>";
         my $url;