-
-
Save beckyconning/d91013aed1d17f6c21942aae09053f80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getCollection("__quasar\\.tmp_b6dfc67c_44").aggregate(↵[↵{↵ | |
"$project": {↵ | |
"s": "$$ROOT", | |
↵"o": {↵ | |
"$objectToArray": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$$ROOT"] | |
}, ↵ { | |
"$lt": ["$$ROOT", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$$ROOT", ↵ { | |
"$literal": undefined | |
}]↵ | |
}↵ | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ { | |
"$unwind": { | |
"path": "$o" | |
} | |
}, ↵ {↵ | |
"$project": {↵ | |
"identities": {↵ | |
"esh117": {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}↵ | |
}, | |
↵"value": {↵ | |
"original": "$s", | |
↵"0": {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("1") | |
} | |
]↵ | |
}↵ | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ {↵ | |
"$project": {↵ | |
"s": "$$ROOT", | |
↵"o": {↵ | |
"$objectToArray": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.original"] | |
}, ↵ { | |
"$lt": ["$value.original", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.original", ↵ { | |
"$literal": undefined | |
}]↵ | |
}↵ | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ { | |
"$unwind": { | |
"path": "$o" | |
} | |
}, ↵ {↵ | |
"$project": {↵ | |
"0": {↵ | |
"$eq": [↵"$s.identities.esh117", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"1": {↵ | |
"$eq": [↵"$s.identities.esh117", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"2": {↵ | |
"$eq": [↵"$s.identities.esh117", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"3": {↵ | |
"$eq": [↵"$s.identities.esh117", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"src": { | |
"s": "$s", | |
"f": ["$o.k", "$o.v"] | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ {↵ | |
"$match": { | |
"$or": [{ | |
"0": true | |
}, { | |
"1": true | |
}, { | |
"2": true | |
}, { | |
"3": true | |
}] | |
}↵ | |
}, ↵ { | |
"$out": "tmp.gen_4" | |
}], ↵ { | |
"allowDiskUse": true | |
});↵ | |
db.tmp.gen_4.mapReduce(↵function() {↵ | |
emit.apply(↵null, ↵ (function(key, value) {↵ | |
return [↵key, ↵ {↵ | |
"identities": value.src.s.identities, | |
↵"value": {↵ | |
"original": value.src.s.value.original, | |
↵"results": {↵ | |
"left": {↵ | |
"original": value.src.s.value.original, | |
↵"results": value.src.s.value["0"]↵ | |
}, | |
↵"right": value.src.f[1]↵ | |
}↵ | |
}↵ | |
}]↵ | |
})(↵this._id, ↵this))↵ | |
}, ↵function(key, values) { | |
return values[0] | |
}, ↵ { | |
"out": { | |
"replace": "tmp.gen_3", | |
"db": "staging" | |
} | |
});↵ | |
db.tmp.gen_3.aggregate(↵[↵{↵ | |
"$project": {↵ | |
"s": "$value", | |
↵"o": { | |
"$objectToArray": "$value.value.results.left.results" | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ { | |
"$unwind": { | |
"path": "$o" | |
} | |
}, ↵ { | |
"$project": { | |
"s": true, | |
"f": "$o.k", | |
"_id": false | |
} | |
}, ↵ { | |
"$out": "tmp.gen_2" | |
}], ↵ { | |
"allowDiskUse": true | |
});↵ | |
db.tmp.gen_2.mapReduce(↵function() {↵ | |
emit.apply(↵null, ↵ (function(key, value) {↵ | |
return [↵key, ↵ {↵ | |
"identities": (function(__rez) {↵ | |
for (var __attr in (value.s.identities)) | |
if (value.s.identities.hasOwnProperty(__attr)) __rez[__attr] = value.s.identities[__attr];↵ | |
__rez.esh119 = value.f;↵ | |
return __rez↵ | |
})(↵{}), | |
↵"value": { | |
"original": value.s.value, | |
"0": value.f | |
}↵ | |
}]↵ | |
})(↵this._id, ↵this))↵ | |
}, ↵function(key, values) { | |
return values[0] | |
}, ↵ { | |
"out": { | |
"replace": "tmp.gen_1", | |
"db": "staging" | |
} | |
});↵ | |
db.tmp.gen_1.aggregate(↵[↵{↵ | |
"$project": {↵ | |
"s": "$value", | |
↵"o": { | |
"$objectToArray": "$value.value.original.results.right" | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ { | |
"$unwind": { | |
"path": "$o" | |
} | |
}, ↵ {↵ | |
"$project": {↵ | |
"0": {↵ | |
"$eq": [↵"$s.identities.esh119", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"1": {↵ | |
"$eq": [↵"$s.identities.esh119", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"2": {↵ | |
"$eq": [↵"$s.identities.esh119", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"3": {↵ | |
"$eq": [↵"$…": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"1": {↵ | |
"$eq": [↵"$s.identities.esh123", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"2": {↵ | |
"$eq": [↵"$s.identities.esh123", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"3": {↵ | |
"$eq": [↵"$s.identities.esh123", ↵ {↵ | |
"$arrayElemAt": [ | |
["$o.k", "$o.v"], { | |
"$literal": NumberInt("0") | |
} | |
]↵ | |
}]↵ | |
}, | |
↵"src": { | |
"s": "$s", | |
"f": ["$o.k", "$o.v"] | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ {↵ | |
"$match": { | |
"$or": [{ | |
"0": true | |
}, { | |
"1": true | |
}, { | |
"2": true | |
}, { | |
"3": true | |
}] | |
}↵ | |
}, ↵ {↵ | |
"$project": {↵ | |
"identities": "$src.s.identities", | |
↵"value": {↵ | |
"k": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{↵ | |
"$lte": [↵{ | |
"$literal": {} | |
}, ↵"$src.s.value.original.results.left.original"]↵ | |
}, ↵ {↵ | |
"$lt": [↵"$src.s.value.original.results.left.original", ↵ { | |
"$literal": [] | |
}]↵ | |
}]↵ | |
}, ↵"$src.s.value.original.results.left.original.0", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"hour": "$src.s.value.0", | |
↵"value": { | |
"$arrayElemAt": ["$src.f", { | |
"$literal": NumberInt("1") | |
}] | |
}, | |
↵"d": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{↵ | |
"$lte": [{ | |
"$literal": {} | |
}, "$src.s.value.original.original"]↵ | |
}, ↵ {↵ | |
"$lt": ["$src.s.value.original.original", { | |
"$literal": [] | |
}]↵ | |
}]↵ | |
}, ↵"$src.s.value.original.original.d", ↵ { | |
"$literal": undefined | |
}]↵ | |
}↵ | |
}, | |
↵"_id": false↵ | |
}↵ | |
}, ↵ { | |
"$out": "tmp.gen_6" | |
}], ↵ { | |
"allowDiskUse": true | |
});↵ | |
db.tmp.gen_6.mapReduce(↵function() {↵ | |
emit.apply(↵null, ↵ (function(key, value) {↵ | |
return [↵{ | |
"0": value.value.k, | |
"1": value.value.d, | |
"2": value.value.hour | |
}, ↵ { | |
"left": [], | |
"right": [value] | |
}]↵ | |
})(↵this._id, ↵this))↵ | |
}, ↵function(key, values) {↵ | |
var result = { | |
"left": [], | |
"right": [] | |
};↵ | |
values.forEach(↵function(value) {↵ | |
result.left = result.left.concat(value.left);↵ | |
result.right = result.right.concat(value.right)↵ | |
});↵ | |
return result↵ | |
}, ↵ { | |
"out": { | |
"reduce": "tmp.gen_0", | |
"db": "staging", | |
"nonAtomic": true | |
} | |
});↵ | |
db.tmp.gen_6.drop();↵ | |
db.tmp.gen_2.drop();↵ | |
db.tmp.gen_4.drop();↵ | |
db.tmp.gen_7.drop();↵ | |
db.tmp.gen_9.drop();↵ | |
db.tmp.gen_3.drop();↵ | |
db.tmp.gen_8.drop();↵ | |
db.tmp.gen_10.drop();↵ | |
db.tmp.gen_1.drop();↵ | |
db.tmp.gen_0.aggregate(↵[↵{↵ | |
"$match": {↵ | |
"value.left": { | |
"$not": { | |
"$size": NumberInt("0") | |
} | |
}, | |
↵"value.right": { | |
"$not": { | |
"$size": NumberInt("0") | |
} | |
}↵ | |
}↵ | |
}, ↵ { | |
"$unwind": { | |
"path": "$value.right" | |
} | |
}, ↵ { | |
"$unwind": { | |
"path": "$value.left" | |
} | |
}, ↵ {↵ | |
"$project": {↵ | |
"d": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.right.value"] | |
}, ↵ { | |
"$lt": ["$value.right.value", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.right.value.d", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"bounced": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.left.value"] | |
}, ↵ { | |
"$lt": ["$value.left.value", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.left.value.value", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"sent": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.right.value"] | |
}, ↵ { | |
"$lt": ["$value.right.value", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.right.value.value", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"hour": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.right.value"] | |
}, ↵ { | |
"$lt": ["$value.right.value", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.right.value.hour", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"k": {↵ | |
"$cond": [↵{↵ | |
"$and": [↵{ | |
"$lte": [{ | |
"$literal": {} | |
}, "$value.right.value"] | |
}, ↵ { | |
"$lt": ["$value.right.value", { | |
"$literal": [] | |
}] | |
}]↵ | |
}, ↵"$value.right.value.k", ↵ { | |
"$literal": undefined | |
}]↵ | |
}, | |
↵"_id": false↵ | |
}↵ | |
}], ↵ { | |
"allowDiskUse": true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment