From: Ian Jackson Subject: [OSSTEST PATCH 16/25] sg-report-host-history: Break out computeflightsrange Date: Wed, 17 Jun 2015 17:45:12 +0100 Message-ID: <1434559521-8751-17-git-send-email-ian.jackson@eu.citrix.com> References: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z5GT1-0004GR-Od for xen-devel@lists.xenproject.org; Wed, 17 Jun 2015 16:45:35 +0000 In-Reply-To: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org To do database locking coherently, it will be convenient to have this in a function. No functional change. Signed-off-by: Ian Jackson --- sg-report-host-history | 65 +++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index 14f8458..c56ed71 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -58,42 +58,44 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { @ARGV or die $!; -$dbh_tests->begin_work; - -if (!$flightlimit) { - my $flagscond = - '('.join(' OR ', map { "f.hostflag = 'blessed-$_'" } @blessings).')'; - my $nhostsq = db_prepare(<execute(); - my ($nhosts) = $nhostsq->fetchrow_array(); - print DEBUG "COUNTED $nhosts hosts\n"; - $flightlimit = $nhosts * $limit * 2; -} + $nhostsq->execute(); + my ($nhosts) = $nhostsq->fetchrow_array(); + print DEBUG "COUNTED $nhosts hosts\n"; + $flightlimit = $nhosts * $limit * 2; + } -my $minflightsq = db_prepare(<execute(); -my ($minflight) = $minflightsq->fetchrow_array(); -$minflight //= 0; + $minflightsq->execute(); + my ($minflight) = $minflightsq->fetchrow_array(); + $minflight //= 0; -our $flightcond = "(flight > $minflight)"; + $flightcond = "(flight > $minflight)"; +} $dbh_tests->do("SET LOCAL enable_seqscan=false"); # Otherwise the PostgreSQL query planner likes to do a complete scan @@ -243,4 +245,5 @@ sub reporthost ($) { rename "$html_file.new", "$html_file" or die "$html_file $!"; } +computeflightsrange(); reporthost $_ foreach @ARGV; -- 1.7.10.4