@@ -102,9 +102,8 @@ func (d *DataState) getTotal(collection mgo.Collection) (total int, err error) {
102
102
})
103
103
}
104
104
105
- //test
106
- data := []interface {}{}
107
- collection .Pipe (pipeline ).All (& data )
105
+ data := []interface {}{} // TODO wrong data type
106
+ err = collection .Pipe (pipeline ).All (& data )
108
107
} else {
109
108
total , err = collection .Find (filter ).Count ()
110
109
}
@@ -152,8 +151,6 @@ func (d *DataState) getAggregate() (aggregate []bson.M) {
152
151
ids [key ] = fmt .Sprintf ("$_id.%s" , key )
153
152
}
154
153
155
- aggregate = append (aggregate , d .getFirstGrouping ())
156
-
157
154
nbGroups := len (d .Group ) - 1
158
155
for i := nbGroups ; i >= 0 ; i -- {
159
156
group := d .Group [i ]
@@ -214,12 +211,11 @@ func (d *DataState) addAggregates(m bson.M, firstlevel bool) bson.M {
214
211
aggregates := bson.M {}
215
212
216
213
for _ , a := range d .Aggregates {
217
- aggregateKey := fmt . Sprintf ( "$%s" , d . toMongoAggregate ( a . Aggregate ) )
214
+ key := a . getKey ( )
218
215
aggregate := bson.M {
219
- aggregateKey : getAggregateExpression (a , firstlevel ),
216
+ fmt . Sprintf ( "$%s" , d . toMongoAggregate ( a . Aggregate )) : getAggregateExpression (a , firstlevel ),
220
217
}
221
218
222
- key := a .getKey ()
223
219
if agg , ok := aggregates [key ]; ok {
224
220
m , _ := agg .(bson.M )
225
221
m [a .Aggregate ] = aggregate
0 commit comments