mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Extract the query code from CategoryList.find_relevant_topics into a separate method (#26390)
## Why this change? The previous implementation of the method generated the query to find the relevant topics and iterated over the results, processing them. This behavior made difficult reusing or changing the query logic in classes extending `CategoryList`. This commit extracts the query logic into another method called `relevant_topics_query ` which can be reused or overwritten in descendant classes.
This commit is contained in:
parent
7b8d60dc20
commit
abf86271ff
@ -70,7 +70,7 @@ class CategoryList
|
||||
|
||||
private
|
||||
|
||||
def find_relevant_topics
|
||||
def relevant_topics_query
|
||||
@all_topics =
|
||||
Topic
|
||||
.secured(@guardian)
|
||||
@ -104,10 +104,12 @@ class CategoryList
|
||||
end
|
||||
|
||||
@all_topics = TopicQuery.remove_muted_tags(@all_topics, @guardian.user).includes(:last_poster)
|
||||
end
|
||||
|
||||
def find_relevant_topics
|
||||
featured_topics_by_category_id = Hash.new { |h, k| h[k] = [] }
|
||||
|
||||
@all_topics.each do |t|
|
||||
relevant_topics_query.each do |t|
|
||||
# hint for the serializer
|
||||
t.include_last_poster = true
|
||||
t.dismissed = dismissed_topic?(t)
|
||||
|
Loading…
Reference in New Issue
Block a user