From b54054c1d3d3ff827da39e4ce8c55f1429a8d25d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 1 Apr 2013 14:54:53 -0400 Subject: [PATCH] No idea why these tests weren't failing for me in guard when I pushed last time. Fixed! --- lib/topic_query.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index ba7b062fbae..9f69ff1126b 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -28,6 +28,16 @@ class TopicQuery end def order_hotness + + # When anonymous, don't use topic_user + if @user.blank? + return "CASE + WHEN topics.pinned_at IS NOT NULL THEN 100 + ELSE hot_topics.score + (COALESCE(categories.hotness, 5.0) / 11.0) + END DESC" + end + + # When logged in take into accounts what pins you've closed "CASE WHEN (COALESCE(topics.pinned_at, '#{lowest_date}') > COALESCE(tu.cleared_pinned_at, '#{lowest_date}')) THEN 100