Mailing List Archive

[OSSTEST PATCH v2 26/41] sg-report-host-history: Rerganisation: Make mainquery per-host
This moves the loop over hosts into the main program. We are working
our way to a new code structure.

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
sg-report-host-history | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 15866ab6..34216aa2 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -164,7 +164,9 @@ sub jobquery ($$$) {

our %hosts;

-sub mainquery () {
+sub mainquery ($) {
+ my ($host) = @_;
+
our $runvarq //= db_prepare(<<END);
SELECT flight, job, name, status
FROM runvars
@@ -177,13 +179,12 @@ sub mainquery () {
ORDER BY flight DESC
LIMIT $limit * 2
END
- foreach my $host (sort keys %hosts) {
- print DEBUG "MAINQUERY $host...\n";
- $runvarq->execute($host, $minflight);

- $hosts{$host} = $runvarq->fetchall_arrayref({});
- print DEBUG "MAINQUERY $host got ".(scalar @{ $hosts{$host} })."\n";
- }
+ print DEBUG "MAINQUERY $host...\n";
+ $runvarq->execute($host, $minflight);
+
+ $hosts{$host} = $runvarq->fetchall_arrayref({});
+ print DEBUG "MAINQUERY $host got ".(scalar @{ $hosts{$host} })."\n";
}

sub reporthost ($) {
@@ -474,7 +475,9 @@ db_retry($dbh_tests, [], sub {
});

db_retry($dbh_tests, [], sub {
- mainquery();
+ foreach my $host (sort keys %hosts) {
+ mainquery($host);
+ }
});

foreach my $host (sort keys %hosts) {
--
2.20.1