From 495fce569668174b0acf2aa8f4b08bd7f489abf5 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Fri, 11 Aug 2023 14:24:11 -0600 Subject: [PATCH] starting to work on GroupBy aggregations --- backend/pkg/models/query_resource.go | 13 +++++++++++++ .../src/app/models/widget/dashboard-widget-query.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/pkg/models/query_resource.go b/backend/pkg/models/query_resource.go index 97d2eedd2..341d458f4 100644 --- a/backend/pkg/models/query_resource.go +++ b/backend/pkg/models/query_resource.go @@ -1,9 +1,22 @@ package models +type QueryResourceAggregationType string + +const ( + QueryResourceAggregationTypeCountBy QueryResourceAggregationType = "countBy" + QueryResourceAggregationTypeGroupBy QueryResourceAggregationType = "groupBy" + QueryResourceAggregationTypeMinBy QueryResourceAggregationType = "minBy" + QueryResourceAggregationTypeMaxBy QueryResourceAggregationType = "maxBy" +) + // maps to frontend/src/app/models/widget/dashboard-widget-query.ts type QueryResource struct { Use string `json:"use"` Select []string `json:"select"` From string `json:"from"` Where map[string]interface{} `json:"where"` + + //aggregation fields + AggregationParams []string `json:"aggregation_params"` + AggregationType *QueryResourceAggregationType `json:"aggregation_type"` } diff --git a/frontend/src/app/models/widget/dashboard-widget-query.ts b/frontend/src/app/models/widget/dashboard-widget-query.ts index 7793ee154..895c711b7 100644 --- a/frontend/src/app/models/widget/dashboard-widget-query.ts +++ b/frontend/src/app/models/widget/dashboard-widget-query.ts @@ -8,5 +8,5 @@ export class DashboardWidgetQuery { //https://lodash.com/docs/4.17.15#unionBy aggregation_params?: string[] - aggregation_type?: 'countBy' | 'unionBy' | 'groupBy' | 'orderBy' | 'sortBy' | 'minBy' | 'maxBy' | 'sumBy' + aggregation_type?: 'countBy' | 'groupBy' // | 'minBy' | 'maxBy' | 'sumBy' // 'orderBy' | 'sortBy' | }