DEV: Avoid useless join
This commit is contained in:
parent
b3c2b83ad8
commit
e1083c81d3
|
@ -96,14 +96,11 @@ module DiscourseAssign
|
|||
|
||||
Topic.preload_custom_fields(topics, TopicList.preloaded_custom_fields)
|
||||
|
||||
users = User
|
||||
.where("users.id IN (SELECT value::int FROM topic_custom_fields WHERE name = 'assigned_to_id' AND topic_id IN (?))", topics.map(&:id))
|
||||
.joins('join user_emails on user_emails.user_id = users.id AND user_emails.primary')
|
||||
users = User.real
|
||||
.select(AvatarLookup.lookup_columns)
|
||||
.where("users.id IN (SELECT value::int FROM topic_custom_fields WHERE name = 'assigned_to_id' AND topic_id IN (?))", topics.map(&:id))
|
||||
.to_a
|
||||
|
||||
User.preload_custom_fields(users, User.whitelisted_user_custom_fields(guardian))
|
||||
|
||||
users = users.to_h { |u| [u.id, u] }
|
||||
topics.each do |t|
|
||||
if id = t.custom_fields[TopicAssigner::ASSIGNED_TO_ID]
|
||||
|
|
Loading…
Reference in New Issue