From fc090b4568ddbf17642faab4497916d2d5fab6f8 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 25 Jun 2015 16:25:50 -0400 Subject: [PATCH] FIX: With many stickies some latest posts got missed --- lib/topic_query.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 1146ceb6df0..5d35c226236 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -208,7 +208,7 @@ class TopicQuery end unpinned_topics = topics.where("NOT ( #{pinned_clause} )") - pinned_topics = topics.where(pinned_clause) + pinned_topics = topics.dup.offset(nil).where(pinned_clause) per_page = options[:per_page] || per_page_setting limit = per_page unless options[:limit] == false @@ -217,7 +217,7 @@ class TopicQuery if page == 0 (pinned_topics + unpinned_topics)[0...limit] if limit else - offset = (page * per_page - pinned_topics.count) - 1 + offset = (page * per_page) - pinned_topics.count - 1 offset = 0 unless offset > 0 unpinned_topics.offset(offset).to_a end