diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-11-07 14:46:37 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-11-07 14:02:22 +0000 |
| commit | 2dd6d2b98a8b56d045e8d7011713f1becd746544 (patch) | |
| tree | f8ef1dd976d64e5fc364ef0a422022ac9525b924 /dashboard/app | |
| parent | 1c28956a933a7a144648fbc7992e9a164233fca7 (diff) | |
dashboard/app: make coverage period configurable
This change makes amount of coverage columns configurable.
The default width is 4 columns now (months, days, quarters).
Previous default was 12 and was too wide.
Diffstat (limited to 'dashboard/app')
| -rw-r--r-- | dashboard/app/graphs.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/dashboard/app/graphs.go b/dashboard/app/graphs.go index b05636431..2b4ab15ca 100644 --- a/dashboard/app/graphs.go +++ b/dashboard/app/graphs.go @@ -211,6 +211,7 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f return err } ss := r.FormValue("subsystem") + periodType := r.FormValue("period") if periodType == "" { periodType = coveragedb.DayPeriod @@ -219,7 +220,17 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f return fmt.Errorf("only day and month are allowed, but received %s instead, %w", periodType, ErrClientBadRequest) } - periods, err := coveragedb.GenNPeriodsTill(12, civil.DateOf(timeNow(c)), periodType) + + periodCount := r.FormValue("period_count") + if periodCount == "" { + periodCount = "4" + } + nPeriods, err := strconv.Atoi(periodCount) + if err != nil || nPeriods > 12 || nPeriods < 1 { + return fmt.Errorf("periods_count is wrong, expected [1, 12]: %w", err) + } + + periods, err := coveragedb.GenNPeriodsTill(nPeriods, civil.DateOf(timeNow(c)), periodType) if err != nil { return fmt.Errorf("%s: %w", err.Error(), ErrClientBadRequest) } |
