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

[Xen-devel] [OSSTEST PATCH 1/2] sg-report-job-history: Separate out $cond in queries



We are going to want to reuse this, so separate out the computation of
$cond and @params.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 sg-report-job-history |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/sg-report-job-history b/sg-report-job-history
index ee021b6..479e347 100755
--- a/sg-report-job-history
+++ b/sg-report-job-history
@@ -155,24 +155,21 @@ sub processjobbranch ($$) {
     my @test_rows;
 
     my $blessingscond= '('.join(' OR ', map { "blessing=?" } @blessings).')';
-    my $stmt= <<END;
-        SELECT *
-          FROM jobs JOIN flights USING (flight)
-         WHERE job = ?
-           AND $blessingscond
-END
+    my $cond = "job = ? AND $blessingscond";
     my (@params) = ($j, @blessings);
     if (defined $bra) {
-        $stmt .= <<END;
+        $cond .= <<END;
            AND branch = ?
 END
         push @params, $bra;
     }
-    $stmt .= <<END;
+    my $flightsq= $dbh_tests->prepare(<<END);
+        SELECT *
+          FROM jobs JOIN flights USING (flight)
+         WHERE ($cond)
       ORDER BY flight DESC
          LIMIT 100
 END
-    my $flightsq= $dbh_tests->prepare($stmt);
     $flightsq->execute(@params);
 
     while (my $f= $flightsq->fetchrow_hashref()) {
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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