diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b2d4a36b..4c9e2459d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Updated PostComponent.vue, filter out non-text comments. ([a7346f21](https://github.com/pixelfed/pixelfed/commit/a7346f21)) - Updated Profile.vue component, fix v-once bug. ([4d003d00](https://github.com/pixelfed/pixelfed/commit/4d003d00)) - Updated filesystems config, set S3 visibility to public by default. Fixes #2913. ([49a53c27](https://github.com/pixelfed/pixelfed/commit/49a53c27)) +- Updated CommentPipeline, improve parent reply_count calculation. ([ccc94802](https://github.com/pixelfed/pixelfed/commit/ccc94802)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) diff --git a/app/Jobs/CommentPipeline/CommentPipeline.php b/app/Jobs/CommentPipeline/CommentPipeline.php index e0ae491da..3d09b3a97 100644 --- a/app/Jobs/CommentPipeline/CommentPipeline.php +++ b/app/Jobs/CommentPipeline/CommentPipeline.php @@ -59,10 +59,13 @@ class CommentPipeline implements ShouldQueue $target = $status->profile; $actor = $comment->profile; - DB::transaction(function() use($status) { - $status->reply_count = DB::table('statuses')->whereInReplyToId($status->id)->count(); - $status->save(); - }); + if(config('database.default') === 'mysql') { + DB::transaction(function() use($status) { + $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/public/js/spa.js b/public/js/spa.js index 87a550aeb..c2f0e726c 100644 Binary files a/public/js/spa.js and b/public/js/spa.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 5be95f911..99dd21c28 100644 Binary files a/public/mix-manifest.json and b/public/mix-manifest.json differ