PERF: Rely on preload for first_post for TopicBookmarkable (#18066)

In 49a70a37f1 I removed the
topic: :posts preload for TopicBookmarkable, but did not
update the UserTopicBookmarkSerializer to reflect this,
which was causing up to multi-hundred millisecond queries to
be made for each topic bookmark based on the size of the
topic.
This commit is contained in:
Martin Brennan 2022-08-24 16:01:29 +10:00 committed by GitHub
parent 7a58bd8827
commit 4b84236bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ class UserTopicBookmarkSerializer < UserPostTopicBookmarkBaseSerializer
end
def first_post
@first_post ||= topic.posts.find { |post| post.post_number == 1 }
@first_post ||= topic.first_post
end
def deleted