From 386b8b84986264f33a14bd9a8b1fcfe16b8eb8f4 Mon Sep 17 00:00:00 2001 From: James Kiesel Date: Fri, 19 Aug 2016 10:37:32 -0500 Subject: [PATCH] Don't join on tags unnecessarily when matching all tags --- app/controllers/tags_controller.rb | 2 +- lib/topic_query.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index eb25f4732..87412084d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -299,7 +299,7 @@ class TagsController < ::ApplicationController options[:no_tags] = true else options[:tags] = tag_params - options[:match_all_tags] = true if tag_params.size > 1 + options[:match_all_tags] = true end options diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 7189c9e51..baf93ce58 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -459,7 +459,6 @@ class TopicQuery result = result.preload(:tags) if @options[:tags] && @options[:tags].size > 0 - result = result.joins(:tags) if @options[:match_all_tags] # ALL of the given tags: @@ -476,6 +475,7 @@ class TopicQuery end else # ANY of the given tags: + result = result.joins(:tags) if @options[:tags][0].is_a?(Integer) result = result.where("tags.id in (?)", @options[:tags]) else