From 0d780ffbda6af7587c93440b855d1572d7dc250c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 24 Dec 2022 01:19:11 -0700 Subject: [PATCH 1/2] Update reply pipelines, restore reply_count logic --- app/Jobs/CommentPipeline/CommentPipeline.php | 6 ++++++ app/Jobs/StatusPipeline/StatusReplyPipeline.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/app/Jobs/CommentPipeline/CommentPipeline.php b/app/Jobs/CommentPipeline/CommentPipeline.php index f1470c2a..f674b60d 100644 --- a/app/Jobs/CommentPipeline/CommentPipeline.php +++ b/app/Jobs/CommentPipeline/CommentPipeline.php @@ -59,6 +59,12 @@ class CommentPipeline implements ShouldQueue $target = $status->profile; $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(); + } + if ($actor->id === $target->id || $status->comments_disabled == true) { return true; } diff --git a/app/Jobs/StatusPipeline/StatusReplyPipeline.php b/app/Jobs/StatusPipeline/StatusReplyPipeline.php index 8318179f..0fd19f2e 100644 --- a/app/Jobs/StatusPipeline/StatusReplyPipeline.php +++ b/app/Jobs/StatusPipeline/StatusReplyPipeline.php @@ -68,6 +68,12 @@ class StatusReplyPipeline implements ShouldQueue return 1; } + 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(); + } + DB::transaction(function() use($target, $actor, $status) { $notification = new Notification(); $notification->profile_id = $target->id; From 0d157baf1ecac1a91a19da5c3b294c75afd1089b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 24 Dec 2022 01:20:14 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f63baeb..3636b01d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ - Update FederationController, improve inbox/sharedInbox delete handling ([2180a2de](https://github.com/pixelfed/pixelfed/commit/2180a2de)) - Update HashtagController, improve trending hashtag endpoint ([4873c7dd](https://github.com/pixelfed/pixelfed/commit/4873c7dd)) - Fix CustomEmoji, properly handle shortcode updates and delete old copy in case the extension changes ([bc29073a](https://github.com/pixelfed/pixelfed/commit/bc29073a)) +- Update reply pipelines, restore reply_count logic ([0d780ffb](https://github.com/pixelfed/pixelfed/commit/0d780ffb)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)