xielin 5 years ago
parent
commit
612c2aecb6
1 changed files with 5 additions and 1 deletions
  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) -
                 (3 * $postInfo->comment_count) -
                 (10 * $postInfo->dislike_count));
                 (10 * $postInfo->dislike_count));
             $fresh = (Carbon::parse($postInfo['created_at'])->timestamp) - (Carbon::parse("2019-05-01 00:00:00")->timestamp);
             $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->weight = $score;
             $postInfo->save();
             $postInfo->save();
             Redis::srem($key,$postId);
             Redis::srem($key,$postId);