From b3c2b83ad8bccd9946de885fbbdfdd138861c95f Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Fri, 25 Oct 2019 17:35:05 +0530 Subject: [PATCH] DEV: minor refactoring to reduce DB queries. --- lib/topic_assigner.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/topic_assigner.rb b/lib/topic_assigner.rb index 74de111..0272266 100644 --- a/lib/topic_assigner.rb +++ b/lib/topic_assigner.rb @@ -56,11 +56,13 @@ class ::TopicAssigner if post.user && post.topic && post.user.can_assign? can_assign = force || post.topic.custom_fields[ASSIGNED_TO_ID].nil? + return unless can_assign assign_other = assign_other_passes?(post) && mentioned_staff(post) assign_self = assign_self_passes?(post) && post.user + return unless assign_other || assign_self - if can_assign && is_last_staff_post?(post) + if is_last_staff_post?(post) assigner = new(post.topic, post.user) if assign_other assigner.assign(assign_other, silent: true)