[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [OSSTEST PATCH 05/60] history reporting (nfc): Make cache_write_entry into a top-level sub
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- sg-report-host-history | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index 83344a40..fe5b7cc2 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -112,6 +112,27 @@ sub cache_read_existing ($) { close H; } +sub cache_write_entry ($$) { + my ($fh, $jr) = @_; + print $fh "<!-- osstest-report-reuseable"; + my $whash = sub { + my ($h) = @_; + foreach my $k (sort keys %$h) { + next if $k =~ m/^\%/; + $_ = $h->{$k}; + s{[^-+=/~:;_.,\w]}{ sprintf "%%%02x", ord $& }ge; + printf $fh " %s=%s", $k, $_; + } + }; + $whash->($jr); + foreach my $hk (sort keys %$jr) { + next unless $hk =~ m/^\%/; + print $fh " $'"; + $whash->($jr->{$hk}); + } + print $fh " -->\n"; +} + sub computeflightsrange () { if ($flightlimit) { my $minflightsq = db_prepare(<<END); @@ -285,27 +306,6 @@ END print DEBUG "CACHE $hostname $cachehits / ".(scalar @rows) ." of ".(scalar %cache)."\n"; - my $write_cache_entry = sub { - my ($jr) = @_; - print H "<!-- osstest-report-reuseable"; - my $whash = sub { - my ($h) = @_; - foreach my $k (sort keys %$h) { - next if $k =~ m/^\%/; - $_ = $h->{$k}; - s{[^-+=/~:;_.,\w]}{ sprintf "%%%02x", ord $& }ge; - printf H " %s=%s", $k, $_; - } - }; - $whash->($jr); - foreach my $hk (sort keys %$jr) { - next unless $hk =~ m/^\%/; - print H " $'"; - $whash->($jr->{$hk}); - } - print H " -->\n"; - }; - @rows = sort { $b->{finished} <=> $a->{finished} } @rows; print DEBUG "SORTED\n"; @@ -317,7 +317,7 @@ END foreach my $jr (@rows) { if ($wrote++ >= $limit) { - $write_cache_entry->($jr); + cache_write_entry(\*H, $jr); next; } @@ -417,7 +417,7 @@ END print H "<td>" if !$any_power; print H "</td>\n"; - $write_cache_entry->($jr); + cache_write_entry(\*H, $jr); print H "</tr>\n\n"; $alternate ^= 1; -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |