From effde89b0715132b02b868aae3cca5bb7344043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BF=E3=81=A6=E3=82=8B=E3=81=9E?= Date: Tue, 27 Jan 2026 08:05:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20WikiPagesController#index=20=E3=81=A8?= =?UTF-8?q?=20WikiPagesController#search=20=E3=82=92=E7=B5=B1=E5=90=88?= =?UTF-8?q?=EF=BC=88#222=EF=BC=89=20(#240)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #222 Co-authored-by: miteruzo Reviewed-on: https://git.miteruzo.com/miteruzo/btrc-hub/pulls/240 --- .../app/controllers/wiki_pages_controller.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/backend/app/controllers/wiki_pages_controller.rb b/backend/app/controllers/wiki_pages_controller.rb index 135f8d5..20b2912 100644 --- a/backend/app/controllers/wiki_pages_controller.rb +++ b/backend/app/controllers/wiki_pages_controller.rb @@ -2,8 +2,12 @@ class WikiPagesController < ApplicationController rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict def index - pages = WikiPage.all - render json: pages.as_json(methods: [:title]) + title = params[:title].to_s.strip + return render json: WikiPage.all.as_json(methods: [:title]) if title.blank? + + q = WikiPage.joins(:tag_name).includes(:tag_name) + .where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%") + render json: q.limit(20).as_json(methods: [:title]) end def show @@ -122,14 +126,7 @@ class WikiPagesController < ApplicationController end def search - title = params[:title].to_s.strip - - q = WikiPage.joins(:tag_name).includes(:tag_name) - if title.present? - q = q.where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%") - end - - render json: q.limit(20).as_json(methods: [:title]) + index end def changes