Commit 3c1fc31f authored by 陈志良's avatar 陈志良

1

parent 9737f463
......@@ -333,10 +333,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) {
......@@ -350,6 +351,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')
......@@ -377,7 +379,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')
......@@ -400,7 +403,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) {
comment_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')
......@@ -423,6 +427,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'),
......
......@@ -54,6 +54,7 @@ var sendThreadLogRequest = function(open_id, user_agent, origin_ip, method, nick
"source_channel":source_channel, //分享入口渠道(0:官方直接分享;1:微信朋友圈;2:微信好友;3:QQ好友;4:腾讯微博;5:广告组;6:自媒体;)
"source_open_id":source_open_id //分享人的open_id
};
// console.log(obj);
redis.publish('__pi_front_access_log_old__', JSON.stringify(obj), function(err, reply) {
if (err) {
console.error(err);
......@@ -64,7 +65,8 @@ var sendThreadLogRequest = function(open_id, user_agent, origin_ip, method, nick
var getClientIP = function(req) {
var ipAddress;
var headers = req.headers;
var forwardedIpsStr = headers['x-real-ip'] || headers['x-forwarded-for'];
// console.log(headers);
var forwardedIpsStr = headers['remoteip'] || headers['x-real-ip'] || headers['x-forwarded-for'];
if (forwardedIpsStr) {
ipAddress = forwardedIpsStr;
} else {
......
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