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)
|
Topic.preload_custom_fields(topics, TopicList.preloaded_custom_fields)
|
||||||
|
|
||||||
users = User
|
users = User.real
|
||||||
.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')
|
|
||||||
.select(AvatarLookup.lookup_columns)
|
.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
|
.to_a
|
||||||
|
|
||||||
User.preload_custom_fields(users, User.whitelisted_user_custom_fields(guardian))
|
|
||||||
|
|
||||||
users = users.to_h { |u| [u.id, u] }
|
users = users.to_h { |u| [u.id, u] }
|
||||||
topics.each do |t|
|
topics.each do |t|
|
||||||
if id = t.custom_fields[TopicAssigner::ASSIGNED_TO_ID]
|
if id = t.custom_fields[TopicAssigner::ASSIGNED_TO_ID]
|
||||||
|
|
Loading…
Reference in New Issue