Commit fcdd288b authored by 陈家荣's avatar 陈家荣

优化帖子报表代码

parent fc45c344
......@@ -89,6 +89,22 @@ function mapReduce(model, match, group, date, callback) {
});
}
//统计数量
function count(model, match, date, callback) {
model.count(match, function(err, count) {
if (err) {
console.error(err);
callback(err, null);
} else {
var data = {
date: date,
count: count
};
callback(null, data);
}
});
}
//统计
function countSex(t_id, sex, callback) {
......@@ -366,15 +382,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
}
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumUserThreadControl, match, group, d, cont);
count(ForumUserThreadControl, match, d, cont);
});
});
......@@ -390,15 +398,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumPraiseLog, match, group, d, cont);
count(ForumPraiseLog, match, d, cont);
});
});
......@@ -414,15 +414,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumComment, match, group, d, cont);
count(ForumComment, match, d, cont);
});
});
......@@ -438,15 +430,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumShareLog, match, group, d, cont);
count(ForumShareLog, match, d, cont);
});
});
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment