Skip to content

Conversation

@karlley
Copy link
Contributor

@karlley karlley commented Oct 7, 2025

Issue

概要

企業一覧・詳細表示機能をReactからRails viewに移行

変更確認方法

  1. chore/replace-users-companies-to-rails-view をローカルに取り込む
  2. データ初期化(テスト用ユーザーを当日の日付で作成するため)
  3. 開発環境起動
git fetch origin chore/replace-users-companies-to-rails-view
git switch -c chore/replace-users-companies-to-rails-view
bundle exec rails db:seed
foreman start -f Procfile.dev

各項目ごとに以下を確認

表示とリンク

  1. komagata でログイン
  2. ユーザー一覧画面(/users/companies)にアクセスし、企業タブを選択
  3. 以下が表示されていることを確認
  • 企業ロゴ
  • 企業名
  • 企業に属するユーザーのアイコン
  1. 以下のクリック時の遷移を確認
  • 企業名: 企業詳細画面(/companies/:id/users)
  • ユーザーのアイコン: ユーザー詳細画面(/users/:id)

ロールでのフィルタリング

  1. komagata でログイン
  2. ユーザー一覧画面(/users/companies)にアクセスし、企業タブを選択
  3. 研修生 ~ 管理者までのロールタブを選択して以下を確認
  • 選択中のタブのロールのユーザーアイコンのみが表示される
  • 表示中の企業に所属するユーザーのアイコンのみが表示される
  • ユーザーが所属していない空の企業は表示されない
  • 選択中のロールタブのaタグに.is-active が付与され、選択色になっている
is-active

レスポンシブ対応

  1. komagata でログイン
  2. ユーザー一覧画面(/users/companies)にアクセスし、企業タブを選択
  3. ブラウザの開発者ツールを開き、デバイスモードをスマホに切り替える
  4. レスポンシブデザインが維持されていることを確認

新規ユーザー用アイコンの追加デザイン

  1. komagata でログイン
  2. ユーザー一覧画面(/users/companies)にアクセスし、企業タブを選択
  3. メンターロールタブを選択し、ニューメンター ユーザーのアイコンで以下を確認
  • アイコン外側のspanタグに.is-new-user クラスが付与され、新規ユーザー用デザインが追加されている
is-new-user

Screenshot

見た目の変更はありません

Summary by CodeRabbit

  • 新機能

    • 会社一覧をサーバー側レンダリングで表示し、各社のユーザーアイコンをカード内に整然と表示。タブで表示対象を切替、ユーザーがいない会社は非表示。
  • リファクタ

    • クライアント側の会社表示Reactコンポーネント群を撤廃し、サーバー側ビューへ統合。
  • チョア

    • テスト用フィクスチャに新規ユーザー(new-mentor)等を追加。
  • テスト

    • 関連する統合APIテストと対応するAPIルート/API用ビューを削除。

Closes #9047

@github-actions github-actions bot requested a review from komagata October 7, 2025 21:07
@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

API の companies エンドポイント(コントローラ、Jbuilder、ルート、統合テスト)と複数の React コンポーネントを削除し、Users::CompaniesController#index を拡張してサーバーサイドの Slim 部分テンプレート群へ移行。new-mentor 関連フィクスチャを追加。

Changes

Cohort / File(s) Summary
API の削除
app/controllers/api/users/companies_controller.rb, app/views/api/users/companies/_company.json.jbuilder, app/views/api/users/companies/index.json.jbuilder, test/integration/api/users/companies_test.rb, config/routes/api.rb
API::Users::CompaniesController とそれに紐づく Jbuilder テンプレート、統合テスト、および API ルート(users/companies#index)を削除。
React コンポーネント撤去
app/javascript/components/Companies.jsx, app/javascript/components/Company.jsx, app/javascript/components/LoadingUsersPageCompaniesPlaceholder.jsx, app/javascript/components/LoadingUsersPageCompanyPlaceholder.jsx, app/javascript/components/LoadingUserIconPlaceholder.jsx
会社一覧・会社カード・ユーザーアイコン・ローディング用の React コンポーネント群を削除。
サーバーサイド View 追加/更新
app/views/users/companies/_companies.html.slim, app/views/users/companies/_company.html.slim, app/views/users/companies/_user_icon.html.slim, app/views/users/companies/_users_tabs.html.slim, app/views/users/companies/index.html.slim
React から Slim 部分テンプレートへ移行。companies, company, user_icon の partial を追加・更新し、タブや company ごとのユーザー描画をサーバー側で行うように変更。
コントローラ更新
app/controllers/users/companies_controller.rb
Users::CompaniesController#index を変更:allowed_targets を扱い、ロゴ付き会社を取得、company_ids でユーザーを絞り users_role フィルタを適用して company_id ごとにグルーピングし @company_users を構築。
フィクスチャ追加
db/fixtures/users.yml, db/fixtures/discord_profiles.yml, db/fixtures/talks.yml
new-mentor ユーザーおよび関連する discord_profile / talk のフィクスチャを追加。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Browser
  participant Controller as Users::CompaniesController#index
  participant CompanyModel as Company
  participant UserModel as User
  participant Views as Slim Partials

  Browser->>Controller: GET /users/companies?target=...
  Controller->>CompanyModel: Company.with_attached_logo.order(created_at: :desc)
  Controller->>Controller: company_ids = @companies.map(&:id)
  Controller->>UserModel: where(company_id: company_ids).users_role(target, allowed_targets).order(:id)
  Controller->>Controller: group users by company_id => @company_users
  Controller->>Views: render index (companies, company_users, target, allowed_targets)
  Views->>Views: render _users_tabs
  Views->>Views: render _companies (each) -> _company -> _user_icon (each)
  Views-->>Browser: HTML response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

雑事

Suggested reviewers

  • komagata

Poem

ぴょんと跳んでJSはおしまい
サーバー描画で輪がつながる
会社の門にユーザーが並び
タブが静かに選ばれてゆく
うさぎが祝う、このマージの日 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed Linked issue #9047の要求に沿ってコントローラーの修正、Railsビューとpartialの追加、不要なReactコンポーネントと関連テストの削除が行われており、主要な開発要件を満たしています。
Out of Scope Changes Check ✅ Passed DBフィクスチャの追加は新規ユーザーアイコンの表示検証に必要であり、その他の変更もReact除去とRailsビュー移行の範囲内で完結しているため、想定外の変更はありません。
Description Check ✅ Passed プルリクエストの説明にはIssue番号、概要、変更確認方法、およびスクリーンショットに関するセクションが含まれており、テンプレートの必須要素が十分に記載されています。
Title Check ✅ Passed このプルリクエストのタイトル「企業一覧・詳細表示機能をReactからRails viewに移行する」は、変更セットの主要な変更を正確に反映しています。React コンポーネント(Companies.jsx、Company.jsx など複数のコンポーネント)の削除、API エンドポイントの削除、そして対応する Rails ビューと部分テンプレート(_companies.html.slim、_company.html.slim など)の追加という実装が、タイトルで説明されているアーキテクチャの移行と完全に一致しています。タイトルは簡潔で、具体的であり、スキャンしている開発者にとって主要な変更内容が明確に理解できます。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/replace-users-companies-to-rails-view

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/controllers/users/companies_controller.rb (1)

9-12: QueryObjectパターンの検討を推奨

9〜12行目のデータ取得・フィルタリング・グルーピングのロジックがコントローラに直接実装されています。コーディングガイドラインに従い、この複雑なActiveRecordクエリをQueryObjectパターンで抽出することを検討してください(rails-patterns gemのQuery機能を使用)。

理由:

  • 複数のチェーンされたクエリ操作を含む
  • 将来的に再利用可能性がある
  • テスタビリティの向上
  • Fat Controllerを避けるため

[As per coding guidelines]

例えば以下のようなQueryObjectを作成できます:

# app/queries/company_users_query.rb
class CompanyUsersQuery < Patterns::Query
  queries User
  
  def initialize(company_ids:, target:, allowed_targets:)
    @company_ids = company_ids
    @target = target
    @allowed_targets = allowed_targets
  end
  
  def query
    relation
      .with_attached_avatar
      .where(company_id: @company_ids)
      .users_role(@target, allowed_targets: @allowed_targets)
      .order(:id)
  end
end

そしてコントローラでは:

def index
  @target = ALLOWED_TARGETS.include?(params[:target]) ? params[:target] : ALLOWED_TARGETS.first
  @allowed_targets = ALLOWED_TARGETS
  @companies = Company.with_attached_logo.order(created_at: :desc)
  company_ids = @companies.pluck(:id)
  filtered_users = CompanyUsersQuery.new(
    company_ids: company_ids,
    target: @target,
    allowed_targets: @allowed_targets
  ).all
  @company_users = filtered_users.group_by(&:company_id)
end
app/views/users/companies/_company.html.slim (1)

12-15: 空のユーザーリストの場合のUI表示を検討してください。

company_usersが空の場合、空の.a-user-icons__items要素のみがレンダリングされます。ユーザーがいない会社の場合、「該当するユーザーがいません」などのメッセージを表示することで、UXが向上する可能性があります。

以下のdiffを適用して、空の状態のメッセージを追加できます:

   .a-user-icons
     .a-user-icons__items
-      - company_users.each do |company_user|
-        = render 'user_icon', company_user: company_user
+      - if company_users.any?
+        - company_users.each do |company_user|
+          = render 'user_icon', company_user: company_user
+      - else
+        .a-user-icons__empty-message
+          | ユーザーがいません
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a61fa1 and 8ef72eb.

📒 Files selected for processing (18)
  • app/controllers/api/users/companies_controller.rb (0 hunks)
  • app/controllers/users/companies_controller.rb (1 hunks)
  • app/javascript/components/Companies.jsx (0 hunks)
  • app/javascript/components/Company.jsx (0 hunks)
  • app/javascript/components/LoadingUserIconPlaceholder.jsx (0 hunks)
  • app/javascript/components/LoadingUsersPageCompaniesPlaceholder.jsx (0 hunks)
  • app/javascript/components/LoadingUsersPageCompanyPlaceholder.jsx (0 hunks)
  • app/views/api/users/companies/_company.json.jbuilder (0 hunks)
  • app/views/api/users/companies/index.json.jbuilder (0 hunks)
  • app/views/users/companies/_companies.html.slim (1 hunks)
  • app/views/users/companies/_company.html.slim (1 hunks)
  • app/views/users/companies/_user_icon.html.slim (1 hunks)
  • app/views/users/companies/_users_tabs.html.slim (1 hunks)
  • app/views/users/companies/index.html.slim (2 hunks)
  • db/fixtures/discord_profiles.yml (1 hunks)
  • db/fixtures/talks.yml (1 hunks)
  • db/fixtures/users.yml (1 hunks)
  • test/integration/api/users/companies_test.rb (0 hunks)
💤 Files with no reviewable changes (9)
  • app/controllers/api/users/companies_controller.rb
  • app/javascript/components/LoadingUserIconPlaceholder.jsx
  • app/javascript/components/Companies.jsx
  • app/javascript/components/LoadingUsersPageCompaniesPlaceholder.jsx
  • app/views/api/users/companies/index.json.jbuilder
  • test/integration/api/users/companies_test.rb
  • app/views/api/users/companies/_company.json.jbuilder
  • app/javascript/components/LoadingUsersPageCompanyPlaceholder.jsx
  • app/javascript/components/Company.jsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rb

⚙️ CodeRabbit configuration file

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • app/controllers/users/companies_controller.rb
🧬 Code graph analysis (1)
app/controllers/users/companies_controller.rb (1)
app/models/user.rb (1)
  • users_role (510-514)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (9)
db/fixtures/users.yml (1)

1536-1557: LGTM!

新しいメンターユーザーのフィクスチャが適切に追加されています。既存のエントリと一貫性があり、必要なフィールドがすべて含まれています。

app/views/users/companies/_user_icon.html.slim (1)

1-3: LGTM!

ユーザーアイコンのパーシャルが適切に実装されています。条件付きクラスの適用やデータ属性の設定も正しく行われています。

db/fixtures/talks.yml (1)

235-237: LGTM!

新しいメンターユーザーのトークフィクスチャが適切に追加されています。

db/fixtures/discord_profiles.yml (1)

334-337: LGTM!

新しいメンターユーザーのDiscordプロファイルフィクスチャが適切に追加されています。

app/views/users/companies/_companies.html.slim (1)

1-6: LGTM!

企業一覧のパーシャルが適切に実装されています。ユーザーのいない企業をスキップするロジックも正しく実装されています。

app/views/users/companies/index.html.slim (2)

14-14: LGTM!

サーバーサイドレンダリングへの移行が適切に行われています。必要なローカル変数が正しく渡されています。


24-24: LGTM!

企業一覧パーシャルへのデータの受け渡しが適切に行われています。

app/views/users/companies/_users_tabs.html.slim (1)

4-8: LGTM!

定数からローカル変数への移行が適切に行われています。変数名も明確で、アクティブタブのロジックも正しく更新されています。

app/views/users/companies/_company.html.slim (1)

4-6: フォールバック画像が実装済みです
Company#logo_url/images/companies/logos/default.png へのフォールバックが定義されているため、nilチェックは不要です。

@karlley karlley force-pushed the chore/replace-users-companies-to-rails-view branch from 8ef72eb to eed402a Compare October 8, 2025 02:50
@karlley
Copy link
Contributor Author

karlley commented Oct 8, 2025

@hirokiej
お疲れさまです!
レビューを依頼させていただきたいのですが対応可能でしょうか?🙇‍♂️

@hirokiej
Copy link
Contributor

hirokiej commented Oct 8, 2025

@karlley さん
お疲れ様です!
ごめんなさい、現在issueを全て終わらせマージ待ち状態なのでチーム開発はほぼ修了だと自認しております。
そのため、他の方にご依頼いただけますと幸いです🙇

@karlley
Copy link
Contributor Author

karlley commented Oct 8, 2025

@hirokiej
承知しました!
別の方に依頼させていただきます🙆🏽‍♂️

@karlley
Copy link
Contributor Author

karlley commented Oct 8, 2025

@kutimiti1234
お疲れさまです!
レビューを依頼させていただきたいのですが対応可能でしょうか?🙇‍♂️

viewからcontrollerの定数を直接参照しないように修正

企業への間違ったURLを修正
不要になったルーティングの削除
@karlley karlley force-pushed the chore/replace-users-companies-to-rails-view branch from 5afca19 to 3e5d475 Compare October 9, 2025 21:29
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/controllers/users/companies_controller.rb (2)

9-12: ページネーションとQueryObjectパターンの検討を推奨します。

現在の実装では、すべての企業とユーザーをメモリにロードしています。企業数やユーザー数が増えた場合、パフォーマンスとメモリ使用量の問題が発生する可能性があります。

コーディングガイドラインに従い、以下の改善を検討してください:

  1. ページネーション: 企業やユーザーの数が多い場合、ページネーション(kaminari等)の導入を検討してください。
  2. QueryObjectパターン: 11行目の複雑なクエリチェーンは、rails-patterns gemのQueryObjectパターンでカプセル化することで、可読性と再利用性が向上します。

例:

# app/queries/company_users_query.rb
class CompanyUsersQuery < Patterns::Query
  queries User

  def initialize(company_ids:, target:, allowed_targets:)
    @company_ids = company_ids
    @target = target
    @allowed_targets = allowed_targets
  end

  def query
    relation
      .with_attached_avatar
      .where(company_id: @company_ids)
      .users_role(@target, allowed_targets: @allowed_targets)
      .order(:id)
  end
end

コントローラーでの使用:

def index
  @target = ALLOWED_TARGETS.include?(params[:target]) ? params[:target] : ALLOWED_TARGETS.first
  @allowed_targets = ALLOWED_TARGETS
  @companies = Company.with_attached_logo.order(created_at: :desc)
  
  filtered_users = CompanyUsersQuery.new(
    company_ids: @companies.map(&:id),
    target: @target,
    allowed_targets: @allowed_targets
  ).to_a
  
  @company_users = filtered_users.group_by(&:company_id)
end

Based on coding guidelines


11-11: 長い行を分割することを検討してください。

11行目のクエリチェーンが長く、可読性が低下しています。メソッドチェーンを複数行に分割するか、前述のQueryObjectパターンを使用することで改善できます。

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5afca19 and 3e5d475.

📒 Files selected for processing (19)
  • app/controllers/api/users/companies_controller.rb (0 hunks)
  • app/controllers/users/companies_controller.rb (1 hunks)
  • app/javascript/components/Companies.jsx (0 hunks)
  • app/javascript/components/Company.jsx (0 hunks)
  • app/javascript/components/LoadingUserIconPlaceholder.jsx (0 hunks)
  • app/javascript/components/LoadingUsersPageCompaniesPlaceholder.jsx (0 hunks)
  • app/javascript/components/LoadingUsersPageCompanyPlaceholder.jsx (0 hunks)
  • app/views/api/users/companies/_company.json.jbuilder (0 hunks)
  • app/views/api/users/companies/index.json.jbuilder (0 hunks)
  • app/views/users/companies/_companies.html.slim (1 hunks)
  • app/views/users/companies/_company.html.slim (1 hunks)
  • app/views/users/companies/_user_icon.html.slim (1 hunks)
  • app/views/users/companies/_users_tabs.html.slim (1 hunks)
  • app/views/users/companies/index.html.slim (2 hunks)
  • config/routes/api.rb (0 hunks)
  • db/fixtures/discord_profiles.yml (1 hunks)
  • db/fixtures/talks.yml (1 hunks)
  • db/fixtures/users.yml (1 hunks)
  • test/integration/api/users/companies_test.rb (0 hunks)
💤 Files with no reviewable changes (10)
  • app/views/api/users/companies/_company.json.jbuilder
  • app/javascript/components/LoadingUserIconPlaceholder.jsx
  • app/controllers/api/users/companies_controller.rb
  • app/javascript/components/LoadingUsersPageCompanyPlaceholder.jsx
  • app/javascript/components/Companies.jsx
  • config/routes/api.rb
  • app/javascript/components/LoadingUsersPageCompaniesPlaceholder.jsx
  • app/views/api/users/companies/index.json.jbuilder
  • test/integration/api/users/companies_test.rb
  • app/javascript/components/Company.jsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • app/views/users/companies/_companies.html.slim
  • db/fixtures/discord_profiles.yml
  • db/fixtures/users.yml
  • app/views/users/companies/_user_icon.html.slim
  • app/views/users/companies/_company.html.slim
  • app/views/users/companies/index.html.slim
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rb

⚙️ CodeRabbit configuration file

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • app/controllers/users/companies_controller.rb
🧬 Code graph analysis (1)
app/controllers/users/companies_controller.rb (1)
app/models/user.rb (1)
  • users_role (510-514)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test

@karlley karlley force-pushed the chore/replace-users-companies-to-rails-view branch from 3e5d475 to a72a42c Compare October 9, 2025 21:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/controllers/users/companies_controller.rb (1)

10-12: QueryObjectパターンの使用を検討してください。

企業とユーザーのフィルタリングロジックが複数行にわたっており、再利用可能な形にできます。

コーディングガイドラインに従い、この複雑なクエリロジックをQueryObjectパターン(rails-patterns gem)で実装することで、可読性と再利用性が向上します。

コーディングガイドラインに基づく

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5d475 and a72a42c.

📒 Files selected for processing (6)
  • app/controllers/users/companies_controller.rb (1 hunks)
  • app/views/users/companies/_companies.html.slim (1 hunks)
  • app/views/users/companies/_company.html.slim (1 hunks)
  • app/views/users/companies/_user_icon.html.slim (1 hunks)
  • app/views/users/companies/_users_tabs.html.slim (1 hunks)
  • app/views/users/companies/index.html.slim (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/views/users/companies/_companies.html.slim
  • app/views/users/companies/_users_tabs.html.slim
  • app/views/users/companies/_company.html.slim
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rb

⚙️ CodeRabbit configuration file

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • app/controllers/users/companies_controller.rb
🧬 Code graph analysis (1)
app/controllers/users/companies_controller.rb (1)
app/models/user.rb (1)
  • users_role (510-514)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (3)
app/views/users/companies/index.html.slim (1)

14-14: 部分テンプレートへのデータ渡しは適切です。

コントローラで準備されたデータを各部分テンプレートに正しく渡しており、Reactからサーバーサイドレンダリングへの移行が適切に実装されています。

Also applies to: 24-24

app/controllers/users/companies_controller.rb (1)

9-9: 企業数が多い場合のパフォーマンスを確認してください。

全ての企業をページネーションなしで読み込んでいます。企業数が多い場合、パフォーマンスの問題が発生する可能性があります。

想定される企業数を確認し、必要に応じてページネーションの実装を検討してください。

app/views/users/companies/_user_icon.html.slim (1)

1-3: company_userのメソッドはUserDecoratorおよびモデルに定義済みです。追加対応不要です

@kutimiti1234
Copy link
Contributor

@karlley
はい。可能となります。1週間ほどお時間いただけますと幸いです。

@karlley
Copy link
Contributor Author

karlley commented Oct 10, 2025

@kutimiti1234
ありがとうございます!
全然急いでいませんのでお手隙の際にお願いします。
よろしくお願いします🙇

@kutimiti1234 kutimiti1234 self-requested a review October 18, 2025 12:22
@kutimiti1234
Copy link
Contributor

@karlley
お待たせしており申し訳ございません。
本件について、特に問題なさそうでしたのでapproveさせていただきます。
N+1問題についても、ユーザー取得毎にクエリが発行されるのを回避していて素晴らしいと思いました。

ただ1点、PRのタイトルはbranch名以外をきちんと設定したほうが良いかなと思いました。

@karlley karlley changed the title Chore/replace users companies to rails view 企業一覧・詳細表示機能をReactからRails viewに移行する Oct 19, 2025
@karlley
Copy link
Contributor Author

karlley commented Oct 19, 2025

@kutimiti1234
確認ありがとうございます!
ご指摘ありがとうございます、PRタイトルを設定するのを忘れていました😅
PRタイトルを修正しました。
タイトルのみの修正なのでそのままメンターレビューに進ませていただきます。
レビューありがとうございました😄

@karlley karlley self-assigned this Oct 19, 2025
@karlley
Copy link
Contributor Author

karlley commented Oct 19, 2025

@komagata
メンバーレビューが完了しましたのでレビューお願いします!

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.

Companies.jsx/Company.jsxをRails viewに移行する

4 participants