DEV: minor refactoring to reduce DB queries.

This commit is contained in:
Vinoth Kannan 2019-10-25 17:35:05 +05:30
parent eb02ac1ef5
commit b3c2b83ad8
1 changed files with 3 additions and 1 deletions

View File

@ -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)