Improve string support for reporter expressions
This commit is contained in:
@@ -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"
|
||||
}]
|
||||
}
|
||||
Reference in New Issue
Block a user