瀏覽代碼

Update StatusReplyPipeline

Daniel Supernault 2 年之前
父節點
當前提交
fe81378808
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 4 0
      app/Jobs/CommentPipeline/CommentPipeline.php
  2. 4 0
      app/Jobs/StatusPipeline/StatusReplyPipeline.php

+ 4 - 0
app/Jobs/CommentPipeline/CommentPipeline.php

@@ -60,6 +60,10 @@ class CommentPipeline implements ShouldQueue
         $actor = $comment->profile;
 
         if(config('database.default') === 'mysql') {
+            $count = DB::select(DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)"), [ 'kid' => $status->id]);
+            $status->reply_count = count($count);
+            $status->save();
+        } else {
             $status->reply_count = $status->reply_count + 1;
             $status->save();
         }

+ 4 - 0
app/Jobs/StatusPipeline/StatusReplyPipeline.php

@@ -70,6 +70,10 @@ class StatusReplyPipeline implements ShouldQueue
         }
 
         if(config('database.default') === 'mysql') {
+            $count = DB::select(DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)"), [ 'kid' => $reply->id]);
+            $reply->reply_count = count($count);
+            $reply->save();
+        } else {
             $reply->reply_count = $reply->reply_count + 1;
             $reply->save();
         }