From 57ba5c59a43b6b2bf32a182d97bd23fc2933d2e8 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 6 Mar 2020 19:07:17 -0600 Subject: [PATCH] tag_aliases/index: fix tag category search options excluding empty tags. Fix Tag.search to not filter out empty tags by default. Set the default in the tags controller instead. Fixes various search pages, namely aliases/implications/wiki pages, that rely on Tag.search and that don't expect it to filter tags out by default. --- app/controllers/tags_controller.rb | 2 +- app/models/tag.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 3ba2ca844..323af4574 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -9,7 +9,7 @@ class TagsController < ApplicationController end def index - @tags = Tag.paginated_search(params) + @tags = Tag.paginated_search(params, hide_empty: true) @tags = @tags.includes(:consequent_aliases) if request.format.html? respond_with(@tags) end diff --git a/app/models/tag.rb b/app/models/tag.rb index 488a8fa9b..b283e42ee 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -847,8 +847,8 @@ class Tag < ApplicationRecord q = q.name_or_alias_matches(params[:name_or_alias_matches]) end - if params[:hide_empty].blank? || params[:hide_empty].to_s.truthy? - q = q.where("post_count > 0") + if params[:hide_empty].to_s.truthy? + q = q.nonempty end if params[:has_wiki].to_s.truthy?