DEV: minor refactoring to reduce DB queries.
This commit is contained in:
parent
eb02ac1ef5
commit
b3c2b83ad8
|
@ -56,11 +56,13 @@ class ::TopicAssigner
|
||||||
|
|
||||||
if post.user && post.topic && post.user.can_assign?
|
if post.user && post.topic && post.user.can_assign?
|
||||||
can_assign = force || post.topic.custom_fields[ASSIGNED_TO_ID].nil?
|
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_other = assign_other_passes?(post) && mentioned_staff(post)
|
||||||
assign_self = assign_self_passes?(post) && post.user
|
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)
|
assigner = new(post.topic, post.user)
|
||||||
if assign_other
|
if assign_other
|
||||||
assigner.assign(assign_other, silent: true)
|
assigner.assign(assign_other, silent: true)
|
||||||
|
|
Loading…
Reference in New Issue