xielin 5 年 前
コミット
612c2aecb6
共有1 個のファイルを変更した5 個の追加1 個の削除を含む
  1. 5 1
      app/Console/Commands/CalcPostWeight.php

+ 5 - 1
app/Console/Commands/CalcPostWeight.php

@@ -56,7 +56,11 @@ class CalcPostWeight extends Command
                 (3 * $postInfo->comment_count) -
                 (10 * $postInfo->dislike_count));
             $fresh = (Carbon::parse($postInfo['created_at'])->timestamp) - (Carbon::parse("2019-05-01 00:00:00")->timestamp);
-            $score = log10($temp) + $fresh / 86400;
+            if($temp){
+                $score = log10($temp) + $fresh / 86400;
+            }else{
+                $score = $fresh / 86400;
+            }
             $postInfo->weight = $score;
             $postInfo->save();
             Redis::srem($key,$postId);