PERF: eliminate query that grabs every post number on topic page.
This commit is contained in:
parent
40b22bf367
commit
27aa0bc056
|
@ -416,10 +416,10 @@ class TopicView
|
|||
end
|
||||
|
||||
def closest_post_to(post_number)
|
||||
closest_posts = filter_post_ids_by("@(post_number - #{post_number})")
|
||||
return nil if closest_posts.empty?
|
||||
closest_post = @filtered_posts.order("@(post_number - #{post_number})").limit(1).pluck(:id)
|
||||
return nil if closest_post.empty?
|
||||
|
||||
filtered_post_ids.index(closest_posts.first) || filtered_post_ids[0]
|
||||
filtered_post_ids.index(closest_post.first) || filtered_post_ids[0]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue