|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
+use App\Models\Post;
|
|
|
use App\Models\PostData;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Console\Command;
|
|
@@ -48,7 +49,8 @@ class CalcPostWeight extends Command
|
|
|
Log::debug('权重帖子ID:' . json_encode($postIds));
|
|
|
foreach ($postIds as $postId) {
|
|
|
$postInfo = PostData::where("post_id", $postId)->first();
|
|
|
- if(empty($postInfo)){
|
|
|
+ $post = Post::find($postId);
|
|
|
+ if(empty($postInfo) || empty($post)){
|
|
|
continue;
|
|
|
}
|
|
|
Log::debug('帖子:' . json_encode($postInfo));
|
|
@@ -64,8 +66,8 @@ class CalcPostWeight extends Command
|
|
|
}else{
|
|
|
$score = $fresh / 86400;
|
|
|
}
|
|
|
- $postInfo->weight = $score;
|
|
|
- $postInfo->save();
|
|
|
+ $post->weight = $score;
|
|
|
+ $post->save();
|
|
|
Redis::srem($key,$postId);
|
|
|
Log::debug(date("Y-m-d H:i:s") . "设置帖子" . $postInfo->post_id . "的权重分为:" . $score);
|
|
|
}
|