Use db schema for tags instead of plugin store and custom fields

This commit is contained in:
Neil Lalonde
2016-05-04 14:02:47 -04:00
parent ebd4b45771
commit f13470b96b
33 changed files with 726 additions and 186 deletions

View File

@@ -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)