FIX: unpinned topics shouldn't remain pinned on categories page

This commit is contained in:
Neil Lalonde
2015-06-10 14:36:47 -04:00
parent e54125b5dc
commit 611b5f996e
4 changed files with 54 additions and 3 deletions

View File

@@ -135,9 +135,10 @@ class TopicQuery
def list_category_topic_ids(category)
query = default_results(category: category.id)
pinned_ids = query.where('pinned_at IS NOT NULL AND category_id = ?', category.id)
.limit(nil)
.order('pinned_at DESC').pluck(:id)
non_pinned_ids = query.where('pinned_at IS NULL OR category_id <> ?', category.id).pluck(:id)
(pinned_ids + non_pinned_ids)[0...@options[:per_page]]
(pinned_ids + non_pinned_ids)
end
def list_new_in_category(category)