Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat filter-summary-per-workload #564

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion go/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/vitessio/arewefastyet/go/tools/github"
"github.com/vitessio/arewefastyet/go/tools/macrobench"
"github.com/vitessio/arewefastyet/go/tools/microbench"
"golang.org/x/exp/slices"
)

type ErrorAPI struct {
Expand Down Expand Up @@ -288,7 +289,23 @@ type dailySummaryResp struct {
}

func (s *Server) getDailySummary(c *gin.Context) {
results, err := macrobench.SearchForLastDaysQPSOnly(s.dbClient, s.benchmarkTypes, macrobench.Gen4Planner, 31)
// Query array allows to get multiple values for the same key
frouioui marked this conversation as resolved.
Show resolved Hide resolved
// For example: /api/daily/summary?workloads=TPCC&workloads=OLTP
workloads := c.QueryArray("workloads")
slog.Infof("workloads: %v", workloads)
if len(workloads) == 0 {
workloads = s.benchmarkTypes
} else {
for _, workload := range workloads {
workload = strings.ToUpper(workload)
slog.Infof("workload: %v", workload)
if !slices.Contains(s.benchmarkTypes, workload) {
c.JSON(http.StatusBadRequest, &ErrorAPI{Error: "Wrong workload specified"})
return
}
}
}
results, err := macrobench.SearchForLastDaysQPSOnly(s.dbClient, workloads, macrobench.Gen4Planner, 31)
if err != nil {
c.JSON(http.StatusInternalServerError, &ErrorAPI{Error: err.Error()})
slog.Error(err)
Expand Down
Loading