このコミットが含まれているのは:
2026-01-28 01:06:21 +09:00
コミット 8273fed69f
5個のファイルの変更53行の追加33行の削除
+5 -2
ファイルの表示
@@ -16,9 +16,12 @@ class TagsController < ApplicationController
q = params[:q].to_s.strip
return render json: [] if q.blank?
with_nico = !(params[:nico].to_s.strip.downcase.in?(['0', 'false', 'off', 'no']))
tags = (Tag.joins(:tag_name).includes(:tag_name)
.where('(tags.category = ? AND tag_names.name LIKE ?) OR tag_names.name LIKE ?',
'nico', "nico:#{ q }%", "#{ q }%")
.where(((with_nico ? '(tags.category = ? AND tag_names.name LIKE ?) OR ' : '') +
'tag_names.name LIKE ?'),
*(with_nico ? ['nico', "nico:#{ q }%"] : []), "#{ q }%")
.order(Arel.sql('post_count DESC, tag_names.name ASC'))
.limit(20))
render json: tags.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])