REGRESSION: incorrect ordering when featuring topics

This commit is contained in:
Sam
2015-02-25 14:24:25 +11:00
parent fe578f9944
commit 3658c21fc5
2 changed files with 22 additions and 1 deletions

View File

@@ -132,7 +132,11 @@ class TopicQuery
end
def list_category_topic_ids(category)
default_results(unordered: true, category: category.id).pluck(:id)
query = default_results(category: category.id)
pinned_ids = query.where('pinned_at IS NOT NULL').order('pinned_at DESC').pluck(:id)
non_pinned_ids = query.where('pinned_at IS NULL').pluck(:id)
(pinned_ids + non_pinned_ids)[0...@options[:per_page]]
end
def list_new_in_category(category)