mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 14:30:45 +08:00
FEATURE: do not show category definition topic on top pages
This commit is contained in:
parent
f52ab7fc77
commit
084f51b013
|
@ -27,21 +27,26 @@ class TopTopic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.remove_invisible_topics
|
def self.remove_invisible_topics
|
||||||
exec_sql("WITH invisible_topics AS (
|
exec_sql("WITH category_definition_topic_ids AS (
|
||||||
|
SELECT COALESCE(topic_id, 0) AS id FROM categories
|
||||||
|
), invisible_topic_ids AS (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM topics
|
FROM topics
|
||||||
WHERE deleted_at IS NOT NULL
|
WHERE deleted_at IS NOT NULL
|
||||||
OR NOT visible
|
OR NOT visible
|
||||||
OR archetype = :private_message
|
OR archetype = :private_message
|
||||||
OR archived
|
OR archived
|
||||||
|
OR id IN (SELECT id FROM category_definition_topic_ids)
|
||||||
)
|
)
|
||||||
DELETE FROM top_topics
|
DELETE FROM top_topics
|
||||||
WHERE topic_id IN (SELECT id FROM invisible_topics)",
|
WHERE topic_id IN (SELECT id FROM invisible_topic_ids)",
|
||||||
private_message: Archetype::private_message)
|
private_message: Archetype::private_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.add_new_visible_topics
|
def self.add_new_visible_topics
|
||||||
exec_sql("WITH visible_topics AS (
|
exec_sql("WITH category_definition_topic_ids AS (
|
||||||
|
SELECT COALESCE(topic_id, 0) AS id FROM categories
|
||||||
|
), visible_topics AS (
|
||||||
SELECT t.id
|
SELECT t.id
|
||||||
FROM topics t
|
FROM topics t
|
||||||
LEFT JOIN top_topics tt ON t.id = tt.topic_id
|
LEFT JOIN top_topics tt ON t.id = tt.topic_id
|
||||||
|
@ -49,12 +54,12 @@ class TopTopic < ActiveRecord::Base
|
||||||
AND t.visible
|
AND t.visible
|
||||||
AND t.archetype <> :private_message
|
AND t.archetype <> :private_message
|
||||||
AND NOT t.archived
|
AND NOT t.archived
|
||||||
|
AND t.id NOT IN (SELECT id FROM category_definition_topic_ids)
|
||||||
AND tt.topic_id IS NULL
|
AND tt.topic_id IS NULL
|
||||||
)
|
)
|
||||||
INSERT INTO top_topics (topic_id)
|
INSERT INTO top_topics (topic_id)
|
||||||
SELECT id
|
SELECT id FROM visible_topics",
|
||||||
FROM visible_topics",
|
private_message: Archetype::private_message)
|
||||||
private_message: Archetype::private_message)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_posts_count_for(period)
|
def self.update_posts_count_for(period)
|
||||||
|
@ -85,6 +90,7 @@ class TopTopic < ActiveRecord::Base
|
||||||
WHERE created_at >= :from
|
WHERE created_at >= :from
|
||||||
AND deleted_at IS NULL
|
AND deleted_at IS NULL
|
||||||
AND NOT hidden
|
AND NOT hidden
|
||||||
|
AND post_type = #{Post.types[:regular]}
|
||||||
GROUP BY topic_id"
|
GROUP BY topic_id"
|
||||||
|
|
||||||
TopTopic.update_top_topics(period, "likes", sql)
|
TopTopic.update_top_topics(period, "likes", sql)
|
||||||
|
@ -113,7 +119,8 @@ class TopTopic < ActiveRecord::Base
|
||||||
SET #{period}_#{sort}_count = c.count
|
SET #{period}_#{sort}_count = c.count
|
||||||
FROM top_topics tt
|
FROM top_topics tt
|
||||||
INNER JOIN (#{inner_join}) c ON tt.topic_id = c.topic_id
|
INNER JOIN (#{inner_join}) c ON tt.topic_id = c.topic_id
|
||||||
WHERE tt.topic_id = top_topics.topic_id", from: start_of(period))
|
WHERE tt.topic_id = top_topics.topic_id",
|
||||||
|
from: start_of(period))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user