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

修改论坛文章获取日期的函数

parent fd1effd0
...@@ -19,6 +19,8 @@ var ForumPvLog = mongoose.model('ForumPVLog'), ...@@ -19,6 +19,8 @@ var ForumPvLog = mongoose.model('ForumPVLog'),
ForumUser = mongoose.model('ForumUser'), ForumUser = mongoose.model('ForumUser'),
ForumThread = mongoose.model('ForumThread'); ForumThread = mongoose.model('ForumThread');
var Mongoose = require('mongoose');
var ObjectId = Mongoose.Types.ObjectId;
module.exports = function(app) { module.exports = function(app) {
app.use('/admin/forum', router); app.use('/admin/forum', router);
...@@ -50,7 +52,11 @@ function date_format(date) { ...@@ -50,7 +52,11 @@ function date_format(date) {
//获取日期之间所有日期 //获取日期之间所有日期
function get_all_date(begin, end) { function get_all_date(begin, end) {
var date_array = []; var date_array = [];
if (begin === end) return date_array; // if (begin === end) return date_array;
if (begin === end){
date_array.push(end.replace(/-/g, "/"));
return date_array;
}
var ab = begin.split('-'); var ab = begin.split('-');
var ae = end.split('-'); var ae = end.split('-');
var db = new Date(); var db = new Date();
...@@ -395,13 +401,14 @@ router.post('/getThreadActionStatistic', function(req, res, next) { ...@@ -395,13 +401,14 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
mapReduce(ForumPraiseLog, match, group, d, cont); mapReduce(ForumPraiseLog, match, group, d, cont);
}); });
}); });
//统计所有评论 //统计所有评论
var comment_tasks = []; var comment_tasks = [];
_.forEach(all_data_array, function(d) { _.forEach(all_data_array, function(d) {
comment_tasks.push(function(cont) { comment_tasks.push(function(cont) {
var match = { var match = {
thread: t_id, // thread: t_id,
thread: new ObjectId(t_id),
created: { created: {
$gte: new Date(d + ' 00:00:00'), $gte: new Date(d + ' 00:00:00'),
$lte: new Date(d + ' 23:59:59') $lte: new Date(d + ' 23:59:59')
......
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