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

Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development

Conflicts:
	app/controllers/admin/forumLog.js
parents fb26d915 3c1fc31f
......@@ -19,8 +19,6 @@ var ForumPvLog = mongoose.model('ForumPVLog'),
ForumUser = mongoose.model('ForumUser'),
ForumThread = mongoose.model('ForumThread');
var Mongoose = require('mongoose');
var ObjectId = Mongoose.Types.ObjectId;
module.exports = function(app) {
app.use('/admin/forum', router);
......@@ -56,7 +54,7 @@ function get_all_date(begin, end) {
if (begin === end){
date_array.push(end.replace(/-/g, "/"));
return date_array;
}
}
var ab = begin.split('-');
var ae = end.split('-');
var db = new Date();
......@@ -112,7 +110,7 @@ function countSex(t_id, sex, callback) {
//社区情况(首页)
router.get('/statistic', function(req, res, next) {
router.get('/statistic', function(req, res, next) {
var yesterday = moment(new Date().getTime() - 24 * 3600 * 1000).format('YYYY-MM-DD'),
before_yesterday = moment(new Date().getTime() - 2 * 24 * 3600 * 1000).format('YYYY-MM-DD');
var ent_code = req.session.user.ent_code,
......@@ -207,10 +205,9 @@ router.get('/statistic', function(req, res, next) {
var y_user = datas[0],
by_user = datas[1],
y_thread = datas[2],
by_thread = datas[3];
all_user = datas[4];
all_thread = datas[5];
by_thread = datas[3],
all_user = datas[4],
all_thread = datas[5];
//计算昨天比前天多 多少 的百分比
var user_rate = (by_user === 0) ? y_user : (y_user / by_user).toFixed(4) - 1,
thread_rate = (by_thread === 0) ? y_thread : (y_thread / by_thread).toFixed(4) - 1;
......@@ -340,10 +337,11 @@ router.post('/getThreadViewStatistic', function(req, res, next) {
//文章行为统计
router.post('/getThreadActionStatistic', function(req, res, next) {
// 1.获取文章的创建日期,和今天的日期,转换成日期数组
var t_id = req.body.t_id;
var begin_time = req.body.beginDate;
var ent_time = req.body.endDate;
var all_data_array = get_all_date(begin_time, ent_time);
var t_id = req.body.t_id,
ent_code = req.session.user.ent_code,
begin_time = req.body.beginDate,
ent_time = req.body.endDate,
all_data_array = get_all_date(begin_time, ent_time);
// 2.根据数组统计PV,UV,行为
if (begin_time && ent_time) {
......@@ -357,6 +355,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) {
userThreadControl_tasks.push(function(cont) {
var match = {
ent_code:ent_code,
created: {
$gte: new Date(d + ' 00:00:00'),
$lte: new Date(d + ' 23:59:59')
......@@ -384,7 +383,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) {
praise_tasks.push(function(cont) {
var match = {
thread: t_id,
ent_code:ent_code,
thread: new mongoose.Types.ObjectId(t_id),
created: {
$gte: new Date(d + ' 00:00:00'),
$lte: new Date(d + ' 23:59:59')
......@@ -401,14 +401,14 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
mapReduce(ForumPraiseLog, match, group, d, cont);
});
});
//统计所有评论
var comment_tasks = [];
_.forEach(all_data_array, function(d) {
comment_tasks.push(function(cont) {
var match = {
// thread: t_id,
thread: new ObjectId(t_id),
ent_code:ent_code,
thread: new mongoose.Types.ObjectId(t_id),
created: {
$gte: new Date(d + ' 00:00:00'),
$lte: new Date(d + ' 23:59:59')
......@@ -431,6 +431,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) {
share_tasks.push(function(cont) {
var match = {
ent_code:ent_code,
thread: t_id,
created: {
$gte: new Date(d + ' 00:00:00'),
......
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