From d08497c308c422788e9eb55ff559f2f57ab0bb5d Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Tue, 8 Dec 2020 13:18:02 -0300 Subject: [PATCH] Revert "FEATURE: show assigned user on search results (#121)" (#122) This reverts commit ed51dcef10b3b1192751eb400fcf8a585763cc46. Plugin triggers a N+1, and the N+1 protection breaks search everywhere StandardError (Attempted to access the non preloaded custom field 'assigned_to_id'. This is disallowed to prevent N+1 queries.) --- plugin.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/plugin.rb b/plugin.rb index 009a64a..7a48c21 100644 --- a/plugin.rb +++ b/plugin.rb @@ -346,20 +346,6 @@ after_initialize do end end - add_to_class(:search_topic_list_item_serializer, :assigned_to_user_id) do - id = object.custom_fields[TopicAssigner::ASSIGNED_TO_ID] - # a bit messy but race conditions can give us an array here, avoid - id && id.to_i rescue nil - end - - add_to_serializer(:search_topic_list_item, :assigned_to_user, false) do - object.assigned_to_user - end - - add_to_serializer(:search_topic_list_item, 'include_assigned_to_user?') do - (SiteSetting.assigns_public || scope.can_assign?) && object.assigned_to_user - end - TopicsBulkAction.register_operation("assign") do if @user.can_assign? assign_user = User.find_by_username(@operation[:username])