BUGFIX: make sure we only show topics that have a useful score in the Top page
This commit is contained in:
parent
d635d888ba
commit
28bf78d801
|
@ -47,7 +47,7 @@ class TopTopic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_views_count_for(period)
|
def self.update_views_count_for(period)
|
||||||
sql = "SELECT parent_id as topic_id, GREATEST(COUNT(*), 1) AS count
|
sql = "SELECT parent_id as topic_id, COUNT(*) AS count
|
||||||
FROM views v
|
FROM views v
|
||||||
WHERE v.viewed_at >= :from
|
WHERE v.viewed_at >= :from
|
||||||
GROUP BY topic_id"
|
GROUP BY topic_id"
|
||||||
|
@ -56,7 +56,7 @@ class TopTopic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_likes_count_for(period)
|
def self.update_likes_count_for(period)
|
||||||
sql = "SELECT topic_id, SUM(like_count) AS count
|
sql = "SELECT topic_id, GREATEST(SUM(like_count), 1) AS count
|
||||||
FROM posts p
|
FROM posts p
|
||||||
WHERE p.created_at >= :from
|
WHERE p.created_at >= :from
|
||||||
AND p.deleted_at IS NULL
|
AND p.deleted_at IS NULL
|
||||||
|
|
|
@ -88,6 +88,7 @@ class TopicQuery
|
||||||
score = "#{period}_score"
|
score = "#{period}_score"
|
||||||
create_list(:top, unordered: true) do |topics|
|
create_list(:top, unordered: true) do |topics|
|
||||||
topics.joins(:top_topic)
|
topics.joins(:top_topic)
|
||||||
|
.where("top_topics.#{score} > 1")
|
||||||
.order("top_topics.#{score} DESC, topics.bumped_at DESC")
|
.order("top_topics.#{score} DESC, topics.bumped_at DESC")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue