diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-09-09 11:58:14 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-09-09 13:32:24 +0000 |
| commit | df6d5ba592799e2e819c8b3447b9a08e7e8d1986 (patch) | |
| tree | 47eab9f8491b01fad881baa0afad6651f093c07e /dashboard | |
| parent | ee18ec07f58b8b246c76570bce69251e735906fe (diff) | |
dashboard/app: use day long aggregations not week long
Current coverage is a week long data merge for every day.
The goal is to show a monthly data by default and
make daily data available for &period=day requests.
This commit makes the first two steps:
1. Make the day a day long, not a week long aggregation.
2. Enable the month long merges available for &period=month.
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/app/graphs.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/dashboard/app/graphs.go b/dashboard/app/graphs.go index f3f62577e..87c7e1403 100644 --- a/dashboard/app/graphs.go +++ b/dashboard/app/graphs.go @@ -192,7 +192,7 @@ func handleFoundBugsGraph(c context.Context, w http.ResponseWriter, r *http.Requ return serveTemplate(w, "graph_histogram.html", data) } -type funcStyleBodyJS func(ctx context.Context, projectID, ns, subsystem string, dateFrom, dateTo civil.Date, +type funcStyleBodyJS func(ctx context.Context, projectID, ns, subsystem string, periods []coveragedb.TimePeriod, ) (template.CSS, template.HTML, template.HTML, error) func handleCoverageHeatmap(c context.Context, w http.ResponseWriter, r *http.Request) error { @@ -209,11 +209,21 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f return err } ss := r.FormValue("subsystem") - dateFrom := civil.DateOf(time.Now().Add(-14 * 24 * time.Hour)) - dateTo := civil.DateOf(time.Now()) + periodType := r.FormValue("period") + if periodType == "" { + periodType = coveragedb.DayPeriod + } + if periodType != coveragedb.DayPeriod && periodType != coveragedb.MonthPeriod { + return fmt.Errorf("only day and month are allowed, but received %s instead", periodType) + } + pOps, err := coveragedb.PeriodOps(periodType) + if err != nil { + return err + } + periods := coveragedb.GenNPeriodsTill(12, civil.DateOf(time.Now()), pOps) var style template.CSS var body, js template.HTML - if style, body, js, err = f(c, "syzkaller", hdr.Namespace, ss, dateFrom, dateTo); err != nil { + if style, body, js, err = f(c, "syzkaller", hdr.Namespace, ss, periods); err != nil { return fmt.Errorf("failed to generate heatmap: %w", err) } return serveTemplate(w, "custom_content.html", struct { @@ -249,11 +259,11 @@ func handleCoverageGraph(c context.Context, w http.ResponseWriter, r *http.Reque if err != nil { return err } - periodEndDates := coveragedb.GenNPeriodEndDatesTill(12, civil.DateOf(time.Now()), pOps) + periodEndDates := coveragedb.GenNPeriodsTill(12, civil.DateOf(time.Now()), pOps) cols := []uiGraphColumn{} for _, periodEndDate := range periodEndDates { - date := periodEndDate.String() + date := periodEndDate.DateTo.String() if _, ok := hist.covered[date]; !ok || hist.instrumented[date] == 0 { cols = append(cols, uiGraphColumn{Hint: date, Vals: []uiGraphValue{{IsNull: true}}}) } else { |
