From 9b07ed3af9726a70ca4ca6ae7169986ab02a9532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Fri, 16 Jul 2021 11:11:39 +0200 Subject: [PATCH] Default column labels to their names --- compose/service/record_datasource.go | 3 +++ pkg/report/step_group.go | 2 ++ store/rdbms/compose_record_datasource.go | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/compose/service/record_datasource.go b/compose/service/record_datasource.go index 4997d003b..52ae2d301 100644 --- a/compose/service/record_datasource.go +++ b/compose/service/record_datasource.go @@ -82,6 +82,9 @@ func (svc record) Datasource(ctx context.Context, ld *report.LoadStepDefinition) c = report.MakeColumnOfKind(k) c.Name = f.Name c.Label = f.Label + if c.Label == "" { + c.Label = c.Name + } cols = append(cols, c) } diff --git a/pkg/report/step_group.go b/pkg/report/step_group.go index 6ef232d42..282baf12b 100644 --- a/pkg/report/step_group.go +++ b/pkg/report/step_group.go @@ -32,6 +32,8 @@ type ( GroupColumn struct { // Name defines the alias for the new column Name string `json:"name"` + // Label defines the user friendly name for the column + Label string `json:"label"` // Expr defines the expression to transform the column Expr string `json:"expr"` // Aggregate defines the aggregation function to apply diff --git a/store/rdbms/compose_record_datasource.go b/store/rdbms/compose_record_datasource.go index eb16414a0..212e96c95 100644 --- a/store/rdbms/compose_record_datasource.go +++ b/store/rdbms/compose_record_datasource.go @@ -123,6 +123,10 @@ func (r *recordDatasource) Group(d report.GroupDefinition, name string) (bool, e // @todo imply based on context c := report.MakeColumnOfKind(g.Kind) c.Name = g.Name + c.Label = g.Label + if c.Label == "" { + c.Label = c.Name + } gCols = append(gCols, c) r.levelColumns[g.Name] = true @@ -153,6 +157,10 @@ func (r *recordDatasource) Group(d report.GroupDefinition, name string) (bool, e col = report.MakeColumnOfKind("Number") } col.Name = c.Name + col.Label = c.Label + if col.Label == "" { + col.Label = col.Name + } gCols = append(gCols, col) r.levelColumns[c.Name] = true