From b31bc6e037af776d2cea3f34c44b02a105b34d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 24 Mar 2025 11:34:48 +0100 Subject: [PATCH] DEV: add `guardian` argument to `TopicsFilter` (#237) As it's been added in discourse/discourse#31908 --- .discourse-compatibility | 1 + plugin.rb | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.discourse-compatibility b/.discourse-compatibility index e195ea5..34a79f4 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 3.5.0.beta2-dev: 7f9a0bb2a75217731de3a0168302b66453152c09 < 3.5.0.beta1-dev: 0390f3611ea3b635877b349e9fb38aac01e19837 < 3.4.0.beta2-dev: 6d52b8cfa8b3e2920aa3f12fc52673b88f53f776 < 3.4.0.beta1-dev: 4ebcd1187b59290b79db8c61c89df9f72bf1363c diff --git a/plugin.rb b/plugin.rb index 4317e9a..98578f8 100755 --- a/plugin.rb +++ b/plugin.rb @@ -119,9 +119,8 @@ after_initialize do add_to_serializer(:current_user, :votes_count) { object.vote_count } add_to_serializer(:current_user, :votes_left) { [object.vote_limit - object.vote_count, 0].max } - filter_order_votes = ->(scope, order_direction) do - scope = scope.joins(:topic_vote_count) - scope.order( + filter_order_votes = ->(scope, order_direction, _guardian) do + scope.joins(:topic_vote_count).order( "COALESCE(topic_voting_topic_vote_count.votes_count, 0)::integer #{order_direction}", ) end