diff mbox series

[OSSTEST,08/13] sg-report-host-history: Write cache entries

Message ID 20191108185001.3319-9-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series Speed up and restore host history | expand

Commit Message

Ian Jackson Nov. 8, 2019, 6:49 p.m. UTC
Write the %$jr contents out in a fairly terse format.  We stuff it
into a parseable SGML/XML comment in the output HTML.

Nothing makes use of this yet - parsing it back in will come later.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-host-history | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/sg-report-host-history b/sg-report-host-history
index 8767b25d..335efa1c 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -246,6 +246,27 @@  END
 	push @rows, { %$jr, %$endedrow };
     }
 
+    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;
     $#rows = $limit-1 if @rows > $limit;
 
@@ -338,6 +359,8 @@  END
         print H "<td>" if !$any_power;
 	print H "</td>\n";
 
+	$write_cache_entry->($jr);
+
 	print H "</tr>\n\n";
 	$alternate ^= 1;
     }