[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [OSSTEST PATCH 14/60] history reporting (nfc): Use cacheable_fn for power methods
Avoids open-coding knowledge of the $jr convention at this use site. %powers becomes %$powers, so it's a bit noisy. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- sg-report-host-history | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index 43ddd2af..9510757f 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -387,12 +387,8 @@ END my $ri = report_run_getinfo({ %$jr, %$ir }); print H "<td $ri->{ColourAttr}>$ri->{Content}</td>\n"; - my %powers; - if ($jr->{'%p'}) { - %powers = %{ $jr->{'%p'} }; - $runvarq_hits++; - } else { - $runvarq_misses++; + my $powers = cacheable_fn($jr, 'b', sub { + my %powers; $jrunvarq->execute($jr->{flight}, $jr->{job}, db_quote_like_pattern($ident)); my %runvars; @@ -404,8 +400,8 @@ END next unless $r =~ m{^\Q${ident}\E_power_}; $powers{$'} = $runvars{$r}; } - $jr->{'%p'} = { %powers }; - } + \%powers; + }); my $skipped = 0; my $any_power = 0; my $pr_power_colour = sub { @@ -421,7 +417,7 @@ END for (; $skipped; $skipped--) { $pr_power_colour->($grey_mid, " - "); } - my $how = $powers{$wh}; + my $how = $powers->{$wh}; my $colour = $how =~ /PDU/ ? $yellow : $how =~ /Combined/ ? $yellow : @@ -430,11 +426,11 @@ END $pr_power_colour->($colour, " $how "); }; foreach my $wh (qw(install recover)) { - $skipped++, next unless exists $powers{$wh}; + $skipped++, next unless exists $powers->{$wh}; $pr_power->($wh); - delete $powers{$wh}; + delete $powers->{$wh}; } - foreach my $wh (sort keys %powers) { + foreach my $wh (sort keys %$powers) { $pr_power->($wh); } print H "<td>" if !$any_power; -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |