FIX: With many stickies some latest posts got missed

This commit is contained in:
Robin Ward 2015-06-25 16:25:50 -04:00
parent 10460330e8
commit fc090b4568
1 changed files with 2 additions and 2 deletions

View File

@ -208,7 +208,7 @@ class TopicQuery
end end
unpinned_topics = topics.where("NOT ( #{pinned_clause} )") 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 per_page = options[:per_page] || per_page_setting
limit = per_page unless options[:limit] == false limit = per_page unless options[:limit] == false
@ -217,7 +217,7 @@ class TopicQuery
if page == 0 if page == 0
(pinned_topics + unpinned_topics)[0...limit] if limit (pinned_topics + unpinned_topics)[0...limit] if limit
else else
offset = (page * per_page - pinned_topics.count) - 1 offset = (page * per_page) - pinned_topics.count - 1
offset = 0 unless offset > 0 offset = 0 unless offset > 0
unpinned_topics.offset(offset).to_a unpinned_topics.offset(offset).to_a
end end