aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/html/pages/stats.go
blob: 45b75ade6d27a61789261c3aa87be854bde222b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2024 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package pages

import (
	"bytes"
	_ "embed"
	"fmt"
	"html/template"

	"github.com/google/syzkaller/pkg/stat"
)

func StatsHTML() (template.HTML, error) {
	buf := new(bytes.Buffer)
	data := stat.RenderGraphs()
	if err := statsTemplate.Execute(buf, data); err != nil {
		return "", fmt.Errorf("failed to execute stats template: %w", err)
	}
	return template.HTML(buf.String()), nil
}

var statsTemplate = Create(statsHTML)

//go:embed stats.html
var statsHTML string