|
@@ -45,22 +45,22 @@ class CalcPostWeight extends Command
|
|
|
$this->line('开始计算权重');
|
|
|
$key = "community_calc_post_score";
|
|
|
$postIds = Redis::smembers($key);
|
|
|
- Log::debug('权重帖子ID:'.json_encode($postIds));
|
|
|
+ Log::debug('权重帖子ID:' . json_encode($postIds));
|
|
|
foreach ($postIds as $postId) {
|
|
|
$postInfo = PostData::where("post_id", $postId)->first();
|
|
|
- Log::debug('帖子:'.json_encode($postInfo));
|
|
|
- $temp = $postInfo['pv'] +
|
|
|
+ Log::debug('帖子:' . json_encode($postInfo));
|
|
|
+ $temp = ($postInfo['pv'] +
|
|
|
(5 * $postInfo->share_cout) +
|
|
|
(2 * $postInfo->praise_count) +
|
|
|
(10 * $postInfo->collect_count) +
|
|
|
(3 * $postInfo->comment_count) -
|
|
|
- (10 * $postInfo->dislike_count);
|
|
|
- Log::debug('帖子temp:'.$temp);
|
|
|
+ (10 * $postInfo->dislike_count));
|
|
|
+ Log::debug('帖子temp:' . $temp);
|
|
|
$fresh = (Carbon::parse($postInfo['created_at'])->timestamp) - (Carbon::parse("2019-05-01 00:00:00")->timestamp);
|
|
|
$score = log10($temp) + $fresh / 86400;
|
|
|
$postInfo->weight = $score;
|
|
|
$postInfo->save();
|
|
|
- $this->line(date("Y-m-d H:i:s")."设置帖子".$postInfo->post_id."的权重分为:".$score);
|
|
|
+ $this->line(date("Y-m-d H:i:s") . "设置帖子" . $postInfo->post_id . "的权重分为:" . $score);
|
|
|
}
|
|
|
}
|
|
|
}
|