Don't join on tags unnecessarily when matching all tags
This commit is contained in:
parent
f27187c9e2
commit
386b8b8498
|
@ -299,7 +299,7 @@ class TagsController < ::ApplicationController
|
||||||
options[:no_tags] = true
|
options[:no_tags] = true
|
||||||
else
|
else
|
||||||
options[:tags] = tag_params
|
options[:tags] = tag_params
|
||||||
options[:match_all_tags] = true if tag_params.size > 1
|
options[:match_all_tags] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
options
|
options
|
||||||
|
|
|
@ -459,7 +459,6 @@ class TopicQuery
|
||||||
result = result.preload(:tags)
|
result = result.preload(:tags)
|
||||||
|
|
||||||
if @options[:tags] && @options[:tags].size > 0
|
if @options[:tags] && @options[:tags].size > 0
|
||||||
result = result.joins(:tags)
|
|
||||||
|
|
||||||
if @options[:match_all_tags]
|
if @options[:match_all_tags]
|
||||||
# ALL of the given tags:
|
# ALL of the given tags:
|
||||||
|
@ -476,6 +475,7 @@ class TopicQuery
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# ANY of the given tags:
|
# ANY of the given tags:
|
||||||
|
result = result.joins(:tags)
|
||||||
if @options[:tags][0].is_a?(Integer)
|
if @options[:tags][0].is_a?(Integer)
|
||||||
result = result.where("tags.id in (?)", @options[:tags])
|
result = result.where("tags.id in (?)", @options[:tags])
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue