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

1

parent 9737f463
...@@ -333,10 +333,11 @@ router.post('/getThreadViewStatistic', function(req, res, next) { ...@@ -333,10 +333,11 @@ router.post('/getThreadViewStatistic', function(req, res, next) {
//文章行为统计 //文章行为统计
router.post('/getThreadActionStatistic', function(req, res, next) { router.post('/getThreadActionStatistic', function(req, res, next) {
// 1.获取文章的创建日期,和今天的日期,转换成日期数组 // 1.获取文章的创建日期,和今天的日期,转换成日期数组
var t_id = req.body.t_id; var t_id = req.body.t_id,
var begin_time = req.body.beginDate; ent_code = req.session.user.ent_code,
var ent_time = req.body.endDate; begin_time = req.body.beginDate,
var all_data_array = get_all_date(begin_time, ent_time); ent_time = req.body.endDate,
all_data_array = get_all_date(begin_time, ent_time);
// 2.根据数组统计PV,UV,行为 // 2.根据数组统计PV,UV,行为
if (begin_time && ent_time) { if (begin_time && ent_time) {
...@@ -350,6 +351,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) { ...@@ -350,6 +351,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) { _.forEach(all_data_array, function(d) {
userThreadControl_tasks.push(function(cont) { userThreadControl_tasks.push(function(cont) {
var match = { var match = {
ent_code:ent_code,
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')
...@@ -377,7 +379,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) { ...@@ -377,7 +379,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) { _.forEach(all_data_array, function(d) {
praise_tasks.push(function(cont) { praise_tasks.push(function(cont) {
var match = { var match = {
thread: t_id, ent_code:ent_code,
thread: new mongoose.Types.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')
...@@ -400,7 +403,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) { ...@@ -400,7 +403,8 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.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, ent_code:ent_code,
thread: new mongoose.Types.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')
...@@ -423,6 +427,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) { ...@@ -423,6 +427,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
_.forEach(all_data_array, function(d) { _.forEach(all_data_array, function(d) {
share_tasks.push(function(cont) { share_tasks.push(function(cont) {
var match = { var match = {
ent_code:ent_code,
thread: t_id, thread: t_id,
created: { created: {
$gte: new Date(d + ' 00:00:00'), $gte: new Date(d + ' 00:00:00'),
......
...@@ -54,6 +54,7 @@ var sendThreadLogRequest = function(open_id, user_agent, origin_ip, method, nick ...@@ -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_channel":source_channel, //分享入口渠道(0:官方直接分享;1:微信朋友圈;2:微信好友;3:QQ好友;4:腾讯微博;5:广告组;6:自媒体;)
"source_open_id":source_open_id //分享人的open_id "source_open_id":source_open_id //分享人的open_id
}; };
// console.log(obj);
redis.publish('__pi_front_access_log_old__', JSON.stringify(obj), function(err, reply) { redis.publish('__pi_front_access_log_old__', JSON.stringify(obj), function(err, reply) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -64,7 +65,8 @@ var sendThreadLogRequest = function(open_id, user_agent, origin_ip, method, nick ...@@ -64,7 +65,8 @@ var sendThreadLogRequest = function(open_id, user_agent, origin_ip, method, nick
var getClientIP = function(req) { var getClientIP = function(req) {
var ipAddress; var ipAddress;
var headers = req.headers; 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) { if (forwardedIpsStr) {
ipAddress = forwardedIpsStr; ipAddress = forwardedIpsStr;
} else { } 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