(enc *encoder, fj fastJsonNode, res *groupResults, fname string)
| 1012 | } |
| 1013 | |
| 1014 | func (sg *SubGraph) addGroupby(enc *encoder, fj fastJsonNode, |
| 1015 | res *groupResults, fname string) error { |
| 1016 | |
| 1017 | // Don't add empty groupby |
| 1018 | if len(res.group) == 0 { |
| 1019 | return nil |
| 1020 | } |
| 1021 | g := enc.newNode(enc.idForAttr(fname)) |
| 1022 | for _, grp := range res.group { |
| 1023 | uc := enc.newNode(enc.idForAttr("@groupby")) |
| 1024 | for _, it := range grp.keys { |
| 1025 | if err := enc.AddValue(uc, enc.idForAttr(it.attr), it.key); err != nil { |
| 1026 | return err |
| 1027 | } |
| 1028 | } |
| 1029 | for _, it := range grp.aggregates { |
| 1030 | if err := enc.AddValue(uc, enc.idForAttr(it.attr), it.key); err != nil { |
| 1031 | return err |
| 1032 | } |
| 1033 | } |
| 1034 | enc.AddListChild(g, uc) |
| 1035 | } |
| 1036 | enc.AddListChild(fj, g) |
| 1037 | return nil |
| 1038 | } |
| 1039 | |
| 1040 | func (sg *SubGraph) addAggregations(enc *encoder, fj fastJsonNode) error { |
| 1041 | for _, child := range sg.Children { |
no test coverage detected