Description
const aggregate : Document [ ] = [
// Group by siteUrl
{
$group : {
_id : {
siteUrl : '$siteUrl' ,
userName : '$userName' ,
featureID : '$featureID' ,
} ,
_total : { $sum : 1 } ,
siteUrl : { $first : '$siteUrl' } ,
siteName : { $first : '$siteName' } ,
} ,
} ,
// Group users
{
$group : {
_id : {
siteUrl : '$_id.siteUrl' ,
featureID : '$_id.featureID' ,
} ,
_total : { $sum : '$_total' } ,
siteUrl : { $first : '$_id.siteUrl' } ,
siteName : { $first : '$siteName' } ,
users : {
$push : {
userName : '$_id.userName' ,
count : '$_total' ,
} ,
} ,
} ,
} ,
// Group features
{
$group : {
_id : {
siteUrl : '$_id.siteUrl' ,
} ,
_total : { $sum : '$_total' } ,
siteUrl : { $first : '$_id.siteUrl' } ,
siteName : { $first : '$siteName' } ,
features : {
$addToSet : {
featureID : '$_id.featureID' ,
count : '$_total' ,
} ,
} ,
users : { $first : '$users' } ,
} ,
} ,
{
$project : {
_id : false ,
} ,
} ,
{ $sort : ctx . sort } ,
{ $limit : ctx . limit + 1 } ,
{ $skip : ctx . offset } ,
]
Met OOM problem
Reactions are currently unavailable
You can’t perform that action at this time.
analytics/api/query.ts
Lines 334 to 392 in a14ef61
Met OOM problem