PERF: use post number to create canoncial path in mega topics.

We don't need page number accuracy in mega topics since it can be expensive.

06d426bd87
This commit is contained in:
Vinoth Kannan 2020-07-06 10:31:19 +05:30
parent 227ddb214e
commit 6d17765924

View File

@ -122,7 +122,7 @@ class TopicView
if @page > 1
"?page=#{@page}"
else
posts_count = unfiltered_posts.where("post_number <= ?", @post_number).count
posts_count = is_mega_topic? ? @post_number : unfiltered_posts.where("post_number <= ?", @post_number).count
page = ((posts_count - 1) / @limit) + 1
page > 1 ? "?page=#{page}" : ""
end