Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function query_month(i, data, callback) {
- query = M_logs.aggregate([
- {
- "$match" : {
- "time" : {
- "$gt" : new Date(now.getFullYear(), i, 1).getTime() / 1000,
- "$lt" : new Date(now.getFullYear(), i + 1, 1).getTime() / 1000
- },
- "from" : "mobile"
- }
- },
- {
- "$group" : {
- "_id" : "$is_newuser",
- "count" : { "$sum" : 1 }
- }
- }
- ]);
- query.exec(function (err, result) {
- if(err) {
- console.log('ERR: ' + err);
- result = [];
- }
- if(result.length === 0) {
- result = [{ _id: 'n', count: 0 }, { _id: 'y', count: 0 }];
- }
- data[i] = result;
- if(i < now.getMonth()) {
- query_month(i + 1, data, callback);
- } else {
- callback(data);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement