From 00d719a50556a183240e61f44eb12733470783cc Mon Sep 17 00:00:00 2001 From: Jad Chahed Date: Wed, 3 Jul 2024 19:22:08 +0200 Subject: [PATCH 1/2] feat: filter-summary-per-workload Signed-off-by: Jad Chahed --- go/server/api.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/go/server/api.go b/go/server/api.go index 9c309c5e1..80735ed24 100644 --- a/go/server/api.go +++ b/go/server/api.go @@ -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 { @@ -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 + // 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) From e05c2111377a55c1673d2c5b797dd4e990869fbb Mon Sep 17 00:00:00 2001 From: Florent Poinsard <35779988+frouioui@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:24:20 -0400 Subject: [PATCH 2/2] Update go/server/api.go Signed-off-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com> --- go/server/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/server/api.go b/go/server/api.go index 80735ed24..c7c7ec406 100644 --- a/go/server/api.go +++ b/go/server/api.go @@ -289,7 +289,7 @@ type dailySummaryResp struct { } func (s *Server) getDailySummary(c *gin.Context) { - // Query array allows to get multiple values for the same key + // Query array allows to get multiple values for the same key // For example: /api/daily/summary?workloads=TPCC&workloads=OLTP workloads := c.QueryArray("workloads") slog.Infof("workloads: %v", workloads)