mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Use db schema for tags instead of plugin store and custom fields
This commit is contained in:
@@ -20,6 +20,7 @@ class TopicQuery
|
||||
topic_ids
|
||||
visible
|
||||
category
|
||||
tags
|
||||
order
|
||||
ascending
|
||||
no_subcategories
|
||||
@@ -451,6 +452,20 @@ class TopicQuery
|
||||
result = result.references(:categories)
|
||||
end
|
||||
|
||||
# ALL TAGS: something like this?
|
||||
# Topic.joins(:tags).where('tags.name in (?)', @options[:tags]).group('topic_id').having('count(*)=?', @options[:tags].size).select('topic_id')
|
||||
|
||||
if @options[:tags] && @options[:tags].size > 0
|
||||
result = result.joins(:tags).preload(:tags)
|
||||
|
||||
# ANY of the given tags:
|
||||
if @options[:tags][0].is_a?(Integer)
|
||||
result = result.where("tags.id in (?)", @options[:tags])
|
||||
else
|
||||
result = result.where("tags.name in (?)", @options[:tags])
|
||||
end
|
||||
end
|
||||
|
||||
result = apply_ordering(result, options)
|
||||
result = result.listable_topics.includes(:category)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user