PERF: Remove category_user lookup when loading private messages.

Private messages do not belong to categories so the query is unnecessary
overhead.
This commit is contained in:
Guo Xiang Tan
2020-09-11 16:26:04 +08:00
parent cd78bcee3a
commit 543e972fec
2 changed files with 26 additions and 2 deletions

View File

@ -48,6 +48,16 @@ describe TopicList do
end
end
describe '#load_topics' do
it 'loads additional data for serialization' do
category_user = CategoryUser.create!(user: user, category: topic.category)
topic = topic_list.load_topics.first
expect(topic.category_user_data).to eq(category_user)
end
end
describe '#top_tags' do
it 'should return the right tags' do
tag = Fabricate(:tag, topics: [topic])