[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OSSTEST PATCH 70/82] sg-report-flight: Refactor runvar access



From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
 sg-report-flight | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 07834581..281361c0 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -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;
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.