PERF: avoid needless queries on non private messages

This commit is contained in:
Sam 2015-09-28 16:40:02 +10:00
parent e5c5744dd5
commit 722e1fc4d0

View file

@ -65,13 +65,13 @@ class TopicViewSerializer < ApplicationSerializer
last_poster: BasicUserSerializer.new(object.topic.last_poster, scope: scope, root: false)
}
if object.topic.allowed_users.present?
if object.topic.private_message?
result[:allowed_users] = object.topic.allowed_users.map do |user|
BasicUserSerializer.new(user, scope: scope, root: false)
end
end
if object.topic.allowed_groups.present?
if object.topic.private_message?
result[:allowed_groups] = object.topic.allowed_groups.map do |ag|
BasicGroupSerializer.new(ag, scope: scope, root: false)
end