Skip to content

Conversation

@batcho0428
Copy link
Collaborator

対応Issue

resolve #1945

概要

  • order_status_check_api_controller.rbにおいて.mapから.includesに変更することで一括取得する形式に変更しSQLの実行回数を削減

実装詳細

  • モデルの修正を必要とするN+1問題に関してはエラー回避のためそのままにしてあります。
  • 申請状況一覧が正常に表示されることは確認済み

画面スクリーンショット等

テスト項目

  • 正しくデータが表示されているか
  • 絞り込み・検索が正しく動作しているか
  • [ ]

備考

  • copilot頼みだったので、何を変更したかは理解できたけど、コード自体は理解できていないので何とかしないといけない。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

このPRは申請状況一覧ページのN+1クエリ問題を修正するやつだよ〜💪 order_status_check_api_controller.rb の2つのメソッドで、関連データを一括取得する .includes を使って、SQLの実行回数をめっちゃ削減してるね✨

Changes:

  • 絞り込み機能(get_refinement_order_status_check)で Group.all から .includes による一括読み込みに変更
  • 検索機能(get_search_order_status_check)で Group.with_order_status_check_narrow_down_by_search_word(word) からコントローラー内での .includes + where クエリに変更し、レスポンス整形処理も追加

Comment on lines +45 to +61
@groups = Group.includes(
:user,
:group_category,
:fes_year,
:sub_rep,
:place_order,
:stage_orders,
:stage_common_option,
:power_orders,
:rental_orders,
:employees,
:public_relation,
:venue_map,
:announcement,
:cooking_process_order,
food_products: :purchase_lists
)
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このN+1問題の修正めっちゃグッドだけど、テストがないんだよね〜😭 他のコントローラーにもテストあんまないっぽいけど、パフォーマンス改善系の変更ってマジで大事だから、最低限「正しくデータが取得できてるか」と「絞り込み/検索が動くか」のテストは欲しいかも!💪 将来的に誰かが .includes 消しちゃっても気づけるようにしたいよね✨

Copilot uses AI. Check for mistakes.
:announcement,
:cooking_process_order,
food_products: :purchase_lists
).where('name LIKE ?', "%#{word}%")
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

検索機能で元々使ってた Group.with_order_status_check_narrow_down_by_search_word(word) から直接SQLに変更してて、これはいいんだけど、where('name LIKE ?', "%#{word}%") の部分でプレースホルダー使ってるのはエライ!👏 でも "%#{word}%" の文字列補完部分でSQLインジェクション対策できてるか気になるかも🤔 Rails的には大丈夫だと思うけど、sanitize_sql_like(word) 使った方がより安全かも!特にワイルドカード文字(%_)がエスケープされるから検索結果も正確になるよ✨

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +61
@groups = Group.includes(
:user,
:group_category,
:fes_year,
:sub_rep,
:place_order,
:stage_orders,
:stage_common_option,
:power_orders,
:rental_orders,
:employees,
:public_relation,
:venue_map,
:announcement,
:cooking_process_order,
food_products: :purchase_lists
)
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同じ .includes の定義が2箇所に重複してるよ〜💦 メンテナビリティ的にヤバめだから、共通のメソッドやスコープに抽出した方がいいかも! 例えば Group モデルに with_order_status_associations みたいなスコープ作って、そこで .includes の定義を一元管理すると、将来アソシエーション追加する時に1箇所直すだけで済むからめっちゃ楽になるよ〜✨

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

えーーーとパフォーマンス改善をしたのならapi ログをください。実際どのくらい良くなったのか分からなかったのでレビューしづらかったです。。。。。

ちょっと私が計測した感じ確かに速度は速くなってました!けどあいまい検索(word指定)のはあまり変わらずでうーんどうしようって感じ。
rails君がmigrationにadd_indexを貼って速度改善できるらしくてそれも試したけど大幅な改善にはならなかった。この辺、時間ある時に再度見てみたいかもーーーー
とりあえずありがとう!!!確かにapi見る感じ、参照している数減ってるから大分良さそうでした!!!!

↓のコメントに貼っておきます。

is_external = params[:is_external].to_i # 0: 指定なし(ALL) 1: true 2: false

@groups = Group.all
@groups = Group.includes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

複数回呼ばれてるから定数にしてまとめよーー
3行目に以下みたいに定数おいて

  ORDER_STATUS_INCLUDES = [
    :user,
    :group_category,
    :fes_year,
    :sub_rep,
    :place_order,
    :stage_orders,
    :stage_common_option,
    :power_orders,
    :rental_orders,
    :employees,
    :public_relation,
    :venue_map,
    :announcement,
    :cooking_process_order,
    { food_products: :purchase_lists }
  ].freeze

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

で、呼ぶときはこんな感じ

    @groups = Group.includes(*ORDER_STATUS_INCLUDES)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あーーごめん、これどっちかといったらmodelsに定義して読んであげる方が良いかも?わっかんねrails

api/app/models/group.rb

  ORDER_STATUS_CHECK_INCLUDES = [
    :user,
    :group_category,
    :fes_year,
    :sub_rep,
    :place_order,
    :stage_orders,
    :stage_common_option,
    :power_orders,
    :rental_orders,
    :employees,
    :public_relation,
    :venue_map,
    :announcement,
    :cooking_process_order,
    { food_products: :purchase_lists }
  ].freeze

  scope :with_order_status_check_relations, -> { includes(*ORDER_STATUS_CHECK_INCLUDES) }

api/app/controller/api/v1/order_status_check_controller.rb

    @groups = Group.with_order_status_check_relations

def get_search_order_status_check
word = params[:word]
@groups = Group.with_order_status_check_narrow_down_by_search_word(word)
@groups = Group.includes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここもー

    @groups = Group.with_order_status_check_relations.where('name LIKE ?', "%#{word}%")

# あいまい検索機能
def get_search_order_status_check
word = params[:word]
@groups = Group.with_order_status_check_narrow_down_by_search_word(word)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

で、with_order_status_check_narrow_down_by_search_wordが使われなくなるからmodelsにあるやつ消してもいいと思う。
レスポンス違うのかなと思ったんだけど、下の変更でfit_groupの型で返ってくるようになってたから削除しちゃっても問題なさそう。
render json: fmt(ok, @groups)
render json: fmt(ok, fit_group_index_for_admin_view(@groups))

@hikahana
Copy link
Contributor

まず、普通のgetの方。

.includes

Started POST "/api/v1/get_refinement_order_status_check" for 172.17.0.1 at 2026-01-20 15:35:45 +0000
API  | Processing by Api::V1::OrderStatusCheckApiController#get_refinement_order_status_check as */*
API  |   Parameters: {"fes_year_id"=>2, "group_category_id"=>0, "is_international"=>0, "is_external"=>0, "order_status_check_api"=>{"fes_year_id"=>2, "group_category_id"=>0, "is_international"=>0, "is_external"=>0}}
API  |   Group Exists? (1.7ms)  SELECT 1 AS one FROM `groups` WHERE `groups`.`fes_year_id` = 2 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:67:in `get_refinement_order_status_check'
API  |   Group Load (0.7ms)  SELECT `groups`.* FROM `groups` WHERE `groups`.`fes_year_id` = 2
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   User Load (0.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   GroupCategory Load (0.8ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` IN (2, 6)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   FesYear Load (0.8ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 2
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   SubRep Load (0.8ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PlaceOrder Load (1.0ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   StageOrder Load (0.9ms)  SELECT `stage_orders`.* FROM `stage_orders` WHERE `stage_orders`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   StageCommonOption Load (0.8ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PowerOrder Load (0.7ms)  SELECT `power_orders`.* FROM `power_orders` WHERE `power_orders`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   RentalOrder Load (0.6ms)  SELECT `rental_orders`.* FROM `rental_orders` WHERE `rental_orders`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   Employee Load (0.7ms)  SELECT `employees`.* FROM `employees` WHERE `employees`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PublicRelation Load (0.6ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   VenueMap Load (0.5ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   Announcement Load (1.6ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   CookingProcessOrder Load (0.9ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   FoodProduct Load (0.9ms)  SELECT `food_products`.* FROM `food_products` WHERE `food_products`.`group_id` IN (3, 5)
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  | Completed 200 OK in 48ms (Views: 0.8ms | ActiveRecord: 15.4ms | Allocations: 13217)

.all

Started POST "/api/v1/get_refinement_order_status_check" for 172.17.0.1 at 2026-01-20 15:37:30 +0000
API  | Processing by Api::V1::OrderStatusCheckApiController#get_refinement_order_status_check as */*
API  |   Parameters: {"fes_year_id"=>2, "group_category_id"=>0, "is_international"=>0, "is_external"=>0, "order_status_check_api"=>{"fes_year_id"=>2, "group_category_id"=>0, "is_international"=>0, "is_external"=>0}}
API  |   Group Exists? (0.6ms)  SELECT 1 AS one FROM `groups` WHERE `groups`.`fes_year_id` = 2 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:68:in `get_refinement_order_status_check'
API  |   Group Load (0.6ms)  SELECT `groups`.* FROM `groups` WHERE `groups`.`fes_year_id` = 2
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:14:in `block in fit_group_index_for_admin_view'
API  |   GroupCategory Load (0.4ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` = 2 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:15:in `block in fit_group_index_for_admin_view'
API  |   FesYear Load (0.5ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 2 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:16:in `block in fit_group_index_for_admin_view'
API  |   SubRep Load (0.5ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:17:in `block in fit_group_index_for_admin_view'
API  |   PlaceOrder Load (0.6ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:18:in `block in fit_group_index_for_admin_view'
API  |   StageOrder Exists? (0.6ms)  SELECT 1 AS one FROM `stage_orders` WHERE `stage_orders`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:19:in `block in fit_group_index_for_admin_view'
API  |   StageCommonOption Load (0.7ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:20:in `block in fit_group_index_for_admin_view'
API  |   PowerOrder Exists? (0.5ms)  SELECT 1 AS one FROM `power_orders` WHERE `power_orders`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:21:in `block in fit_group_index_for_admin_view'
API  |   RentalOrder Exists? (0.5ms)  SELECT 1 AS one FROM `rental_orders` WHERE `rental_orders`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:22:in `block in fit_group_index_for_admin_view'
API  |   Employee Exists? (0.5ms)  SELECT 1 AS one FROM `employees` WHERE `employees`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:23:in `block in fit_group_index_for_admin_view'
API  |   FoodProduct Exists? (0.6ms)  SELECT 1 AS one FROM `food_products` WHERE `food_products`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:24:in `block in fit_group_index_for_admin_view'
API  |   CACHE FoodProduct Exists? (0.1ms)  SELECT 1 AS one FROM `food_products` WHERE `food_products`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:25:in `block in fit_group_index_for_admin_view'
API  |   PublicRelation Load (0.5ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:30:in `block in fit_group_index_for_admin_view'
API  |   VenueMap Load (0.7ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:31:in `block in fit_group_index_for_admin_view'
API  |   Announcement Load (0.5ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:32:in `block in fit_group_index_for_admin_view'
API  |   CookingProcessOrder Load (0.7ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` = 3 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:33:in `block in fit_group_index_for_admin_view'
API  |   User Load (0.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:14:in `block in fit_group_index_for_admin_view'
API  |   GroupCategory Load (0.6ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` = 6 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:15:in `block in fit_group_index_for_admin_view'
API  |   CACHE FesYear Load (0.0ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 2 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:16:in `block in fit_group_index_for_admin_view'
API  |   SubRep Load (0.7ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:17:in `block in fit_group_index_for_admin_view'
API  |   PlaceOrder Load (0.6ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:18:in `block in fit_group_index_for_admin_view'
API  |   StageOrder Exists? (0.6ms)  SELECT 1 AS one FROM `stage_orders` WHERE `stage_orders`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:19:in `block in fit_group_index_for_admin_view'
API  |   StageCommonOption Load (1.5ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:20:in `block in fit_group_index_for_admin_view'
API  |   PowerOrder Exists? (0.6ms)  SELECT 1 AS one FROM `power_orders` WHERE `power_orders`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:21:in `block in fit_group_index_for_admin_view'
API  |   RentalOrder Exists? (0.5ms)  SELECT 1 AS one FROM `rental_orders` WHERE `rental_orders`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:22:in `block in fit_group_index_for_admin_view'
API  |   Employee Exists? (0.6ms)  SELECT 1 AS one FROM `employees` WHERE `employees`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:23:in `block in fit_group_index_for_admin_view'
API  |   FoodProduct Exists? (0.6ms)  SELECT 1 AS one FROM `food_products` WHERE `food_products`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:24:in `block in fit_group_index_for_admin_view'
API  |   CACHE FoodProduct Exists? (0.0ms)  SELECT 1 AS one FROM `food_products` WHERE `food_products`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:25:in `block in fit_group_index_for_admin_view'
API  |   PublicRelation Load (0.6ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:30:in `block in fit_group_index_for_admin_view'
API  |   VenueMap Load (0.5ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:31:in `block in fit_group_index_for_admin_view'
API  |   Announcement Load (0.9ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:32:in `block in fit_group_index_for_admin_view'
API  |   CookingProcessOrder Load (0.7ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` = 5 LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:33:in `block in fit_group_index_for_admin_view'
API  | Completed 200 OK in 170ms (Views: 1.0ms | ActiveRecord: 52.9ms | Allocations: 77533)
API  |
API  |

@hikahana
Copy link
Contributor

でこっちがあいまい検索。

.map


API  | Started POST "/api/v1/get_search_order_status_check" for 172.17.0.1 at 2026-01-21 13:12:59 +0000
API  |    (20.9ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
API  | Processing by Api::V1::OrderStatusCheckApiController#get_search_order_status_check as */*
API  |   Parameters: {"word"=>"nutfes", "order_status_check_api"=>{"word"=>"nutfes"}}
API  |   Group Load (6.5ms)  SELECT `groups`.* FROM `groups` WHERE (name like '%nutfes%')
API  |   ↳ app/models/group.rb:473:in `map'
API  |   User Load (4.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   GroupCategory Load (1.6ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   FesYear Load (1.5ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   SubRep Load (2.1ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   PlaceOrder Load (1.9ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   StageOrder Load (1.4ms)  SELECT `stage_orders`.* FROM `stage_orders` WHERE `stage_orders`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   StageCommonOption Load (1.3ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   PowerOrder Load (1.4ms)  SELECT `power_orders`.* FROM `power_orders` WHERE `power_orders`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   RentalOrder Load (1.7ms)  SELECT `rental_orders`.* FROM `rental_orders` WHERE `rental_orders`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   Employee Load (2.1ms)  SELECT `employees`.* FROM `employees` WHERE `employees`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   PublicRelation Load (1.1ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   VenueMap Load (1.3ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   Announcement Load (1.4ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   CookingProcessOrder Load (1.4ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   FoodProduct Load (1.3ms)  SELECT `food_products`.* FROM `food_products` WHERE `food_products`.`group_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  |   PurchaseList Load (0.9ms)  SELECT `purchase_lists`.* FROM `purchase_lists` WHERE `purchase_lists`.`food_product_id` = 1
API  |   ↳ app/models/group.rb:473:in `map'
API  | Completed 200 OK in 511ms (Views: 2.3ms | ActiveRecord: 71.3ms | Allocations: 95783)

.includes


API  | Started POST "/api/v1/get_search_order_status_check" for 172.17.0.1 at 2026-01-21 13:14:48 +0000
API  | Processing by Api::V1::OrderStatusCheckApiController#get_search_order_status_check as */*
API  |   Parameters: {"word"=>"nutfes", "order_status_check_api"=>{"word"=>"nutfes"}}
API  |   Group Exists? (0.8ms)  SELECT 1 AS one FROM `groups` WHERE (name LIKE '%nutfes%') LIMIT 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:63:in `get_search_order_status_check'
API  |   Group Load (0.6ms)  SELECT `groups`.* FROM `groups` WHERE (name LIKE '%nutfes%')
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   GroupCategory Load (1.0ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   FesYear Load (0.5ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   SubRep Load (0.6ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PlaceOrder Load (0.7ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   StageOrder Load (0.7ms)  SELECT `stage_orders`.* FROM `stage_orders` WHERE `stage_orders`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   StageCommonOption Load (0.8ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PowerOrder Load (0.6ms)  SELECT `power_orders`.* FROM `power_orders` WHERE `power_orders`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   RentalOrder Load (0.7ms)  SELECT `rental_orders`.* FROM `rental_orders` WHERE `rental_orders`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   Employee Load (0.6ms)  SELECT `employees`.* FROM `employees` WHERE `employees`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PublicRelation Load (0.6ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   VenueMap Load (0.5ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   Announcement Load (0.8ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   CookingProcessOrder Load (0.6ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   FoodProduct Load (0.7ms)  SELECT `food_products`.* FROM `food_products` WHERE `food_products`.`group_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  |   PurchaseList Load (0.5ms)  SELECT `purchase_lists`.* FROM `purchase_lists` WHERE `purchase_lists`.`food_product_id` = 1
API  |   ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
API  | Completed 200 OK in 210ms (Views: 0.5ms | ActiveRecord: 67.3ms | Allocations: 99146)

migration試しにしてみたやつ。


Started POST "/api/v1/get_search_order_status_check?word=nut" for 172.17.0.1 at 2026-01-23 07:56:00 +0000
Processing by Api::V1::OrderStatusCheckApiController#get_search_order_status_check as HTML
  Parameters: {"word"=>"nut"}
  Group Exists? (1.2ms)  SELECT 1 AS one FROM `groups` WHERE (name LIKE '%nut%') LIMIT 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:63:in `get_search_order_status_check'
  Group Load (3.1ms)  SELECT `groups`.* FROM `groups` WHERE (name LIKE '%nut%')
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  User Load (0.9ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  GroupCategory Load (0.9ms)  SELECT `group_categories`.* FROM `group_categories` WHERE `group_categories`.`id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  FesYear Load (1.1ms)  SELECT `fes_years`.* FROM `fes_years` WHERE `fes_years`.`id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  SubRep Load (1.0ms)  SELECT `sub_reps`.* FROM `sub_reps` WHERE `sub_reps`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  PlaceOrder Load (1.5ms)  SELECT `place_orders`.* FROM `place_orders` WHERE `place_orders`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  StageOrder Load (2.1ms)  SELECT `stage_orders`.* FROM `stage_orders` WHERE `stage_orders`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  StageCommonOption Load (1.3ms)  SELECT `stage_common_options`.* FROM `stage_common_options` WHERE `stage_common_options`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  PowerOrder Load (1.0ms)  SELECT `power_orders`.* FROM `power_orders` WHERE `power_orders`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  RentalOrder Load (1.2ms)  SELECT `rental_orders`.* FROM `rental_orders` WHERE `rental_orders`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  Employee Load (1.3ms)  SELECT `employees`.* FROM `employees` WHERE `employees`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  PublicRelation Load (0.9ms)  SELECT `public_relations`.* FROM `public_relations` WHERE `public_relations`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  VenueMap Load (1.1ms)  SELECT `venue_maps`.* FROM `venue_maps` WHERE `venue_maps`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  Announcement Load (1.2ms)  SELECT `announcements`.* FROM `announcements` WHERE `announcements`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  CookingProcessOrder Load (0.9ms)  SELECT `cooking_process_orders`.* FROM `cooking_process_orders` WHERE `cooking_process_orders`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  FoodProduct Load (1.4ms)  SELECT `food_products`.* FROM `food_products` WHERE `food_products`.`group_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
  PurchaseList Load (1.7ms)  SELECT `purchase_lists`.* FROM `purchase_lists` WHERE `purchase_lists`.`food_product_id` = 1
  ↳ app/controllers/api/v1/order_status_check_api_controller.rb:11:in `map'
Completed 200 OK in 360ms (Views: 0.9ms | ActiveRecord: 51.2ms | Allocations: 46937)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

申請状況一覧ページのバックエンドリファクタ

3 participants