Improve string support for reporter expressions

This commit is contained in:
Tomaž Jerman
2021-12-10 12:59:20 +01:00
parent 46372f550f
commit a45c914ecf
5 changed files with 121 additions and 0 deletions
@@ -0,0 +1,27 @@
package reporter
import (
"testing"
"github.com/cortezaproject/corteza-server/pkg/report"
)
func Test_group_date_composition(t *testing.T) {
var (
ctx, h, s = setup(t)
m, _, dd = loadScenario(ctx, s, t, h)
ff []*report.Frame
def = dd[0]
)
ff = loadNoErr(ctx, h, m, def)
h.a.Len(ff, 1)
r := ff[0]
h.a.Equal(2, r.Size())
h.a.Equal("by_dob<String>, count<Number>", r.Columns.String())
checkRows(h, ff[0],
"2020-01, 5",
"2021-01, 7")
}
@@ -0,0 +1,38 @@
{
"handle": "testing_report",
"sources": [
{ "step": { "load": {
"name": "users",
"source": "composeRecords",
"definition": {
"module": "user",
"namespace": "ns"
}
}}},
{ "step": { "group": {
"name": "grouped",
"source": "users",
"keys": [
{ "name": "by_dob", "def": "concat(string(year(dob)), '-', string(month(dob)))" }
],
"columns": [
{
"name": "count",
"def": {
"ref": "count"
}
}
]
}}}
],
"frames": [{
"name": "result",
"source": "grouped",
"columns": [
{ "name": "by_dob", "label": "by_dob" },
{ "name": "count", "label": "count" }
],
"sort": "by_dob ASC"
}]
}