Include uncategorized pinned topics on 'Hot'

This commit is contained in:
Robin Ward
2013-04-01 13:49:35 -04:00
parent 79c986dd92
commit 1e6f8dc93a
2 changed files with 23 additions and 2 deletions

View File

@@ -27,6 +27,14 @@ class TopicQuery
END DESC"
end
def order_hotness
"CASE
WHEN (COALESCE(topics.pinned_at, '#{lowest_date}') > COALESCE(tu.cleared_pinned_at, '#{lowest_date}'))
THEN 100
ELSE hot_topics.score + (COALESCE(categories.hotness, 5.0) / 11.0)
END DESC"
end
# If you've clearned the pin, use bumped_at, otherwise put it at the top
def order_nocategory_with_pinned_sql
"CASE
@@ -125,7 +133,7 @@ class TopicQuery
return_list(unordered: true) do |list|
# Find hot topics
list = list.joins(:hot_topic)
.order('hot_topics.score + (COALESCE(categories.hotness, 5.0) / 11.0) desc')
.order(TopicQuery.order_hotness)
end
end