multi_analysis with group_by only gives the data for 1st group
laggingreflex opened this issue · 2 comments
I have this query:
new Keen.Query('count', {
event_collection: 'pageView',
timeframe: 'this_30_days',
interval: 'daily',
group_by: 'user.ip',
});
which results in the expected output:
[ { value:
[ { 'user.ip': '0.0.0.0', result: 1159 },
{ 'user.ip': '109.x.x.145', result: 0 },
{ 'user.ip': '88.x.x.170', result: 0 } ],
timeframe:
{ start: '2016-05-13T18:30:00.000Z',
end: '2016-05-14T18:30:00.000Z' } },
{ value: ...
But I wanted this query as a part of a multi_analysis. So I have this query now:
new Keen.Query('multi_analysis', {
event_collection: 'pageView',
analyses: {
all: {
analysis_type: 'count',
},
unique: {
analysis_type: 'count',
group_by: 'user.ip',
}
},
interval: 'daily',
timeframe: 'this_30_days',
});
This however results in this:
[ { value: { all: 1159, unique: 1159 },
timeframe:
{ start: '2016-05-13T18:30:00.000Z',
end: '2016-05-14T18:30:00.000Z' } },
{ value: { all: 1948, unique: 1948 },
timeframe:
{ start: '2016-05-14T18:30:00.000Z',
end: '2016-05-15T18:30:00.000Z' } },
{ value: { all: 1256, unique: 1256 },
There's all: 1159, unique: 1159
results in which the unique
part seems to only have the data from the first result in the first query
[ { 'user.ip': '0.0.0.0', result: 1159 }, <<
{ 'user.ip': '109.x.x.145', result: 0 }, << where is this data??
{ 'user.ip': '88.x.x.170', result: 0 } ], << and this
Other results than the first one are apparently not being included in multi_analysis.
Is this by design or is it a bug?
@laggingreflex sorry for the oversight here – sharing with our platform team to investigate further 👍
@laggingreflex for multi-analysis queries, group_by
is a top-level parameter -- a sibling to analyses
and timeframe
, and is ignored if passed in as you have it. In this case I would suggest defining running two parallel queries, like so:
var client = new Keen({ /* Configure */ });
var query1 = new Keen.Query('count', {
event_collection: 'pageView',
interval: 'daily',
timeframe: 'this_30_days'
});
var query2 = new Keen.Query('count', {
event_collection: 'pageView',
group_by: 'user.ip',
interval: 'daily',
timeframe: 'this_30_days'
});
client.run([query1, query2], function(err, res) {
// Handle res[0] and res[1]
});