Skip to content

fetcher.jsを廃止しrequest.jsに処理を統一#9334

Merged
komagata merged 9 commits intomainfrom
chore/replace_fetcher_js_with_request_js
Feb 7, 2026
Merged

fetcher.jsを廃止しrequest.jsに処理を統一#9334
komagata merged 9 commits intomainfrom
chore/replace_fetcher_js_with_request_js

Conversation

@yokomaru
Copy link
Copy Markdown
Contributor

@yokomaru yokomaru commented Dec 3, 2025

Issue

概要

  • GETでJSONを取得する共通処理をfetcher.jsから@rails/request.js(get)に置き換え、fetcher.js を削除

影響ファイル

  • React(JSX)
    • BookmarksInDashboard.jsx
    • Products.jsx
    • RegularEvents.jsx
    • Reports.jsx
    • NotificationsBell.jsx
    • TagsInput.jsx
    • Events.jsx
  • JS
    • tag.js

実装方針

  • 現在非React化対応が行われているため、今回修正対応のReactファイルはほぼ削除される想定だがfetcher.jsの削除を優先する
  • ファイルの依存を減らすため、共通処理をカプセル化する新しいラッパーファイルを作らずfetcher.jsを使用している箇所に直接ロジックを記述する(Issue fetcher.jsを撤廃したい #9257 にて駒形さんに確認済み)
  • rails/request.jsjsonをgetterとして定義している(参考)ため、.then(res => res.json) のような記述となっている(関数参照をしているわけではない)

変更確認方法

1)ブランチを取り込む

  • chore/replace_fetcher_js_with_request_jsをローカルに取り込む

2)ローカルサーバの立ち上げ

  • foreman start -f Procfile.dev を実行

3)画面でデータ取得できていることを確認する

kimuraでログインして以下を確認

  • 各データが存在するユーザーであれば他でもOKだが、確実にデータの存在するkimuraで確認する
  • Events.jsxは未使用ファイルのため検証は不要

BookmarksInDashboard.jsx

  • ダッシュボード内に「最新のブックマーク」が表示される
  • ブラウザの開発者ツール(Console)にエラーメッセージが出ていない

NotificationsBell.jsx

  • 右上の通知ベルから最新通知一覧が表示される
  • ブラウザの開発者ツール(Console)にエラーメッセージが出ていない

Reports.jsx

komagataでログインして以下を確認(他の管理者権限のあるユーザーでもOK)

Products.jsx

どの権限ユーザーでもOK

RegularEvents.jsx

タグ入力関連

  • タグ入力・編集フォームは各画面の共通パーツなので代表して1画面で確認
TagsInput.jsx

Adobe Express - 画面収録 2025-12-15 0 50 44

  • ブラウザの開発者ツール(Console)にエラーが出ていない
tag.js

画面収録-2025-12-15-0 48 54

  • ブラウザの開発者ツール(Console)にエラーが出ていない

4) NetWorkタブでAPIレスポンスを確認する(レビュワーの方は確認不要)

  • NetWorkタブでの確認は念の為でおこなったため、PR作成者のみでチェック
NetWorkタブでのステータス確認

NetWorkタブでの確認

  • APIレスポンスが200または304が帰ってくることを確認
    • 1度アクセス済みなどでブラウザキャッシュがある場合は304が返却される
    • 200を返したい場合はブラウザキャッシュをクリアorシークレットウィンドウで実行

確認手順

  • NetWorkタブを開く
  • URLにアクセス
  • 該当のAPIのレスポンスのステータスを確認する

BookmarksInDashboard.jsx

  • bookmarks.jsonのAPIレスポンスが200または304が帰ってくることを確認
スクショ

スクリーンショット 2025-12-15 18 01 17

NotificationsBell.jsx

  • notifications.jsonのAPIレスポンスが200または304が帰ってくることを確認
スクショ

スクリーンショット 2025-12-15 17 59 26

Reports.jsx

  • reports.jsonのAPIレスポンスが200または304が帰ってくることを確認
スクショ

スクリーンショット 2025-12-15 18 02 15

komagataでログインして以下を確認(他の管理者権限のあるユーザーでもOK)

Products.jsx

  • productsのAPIレスポンスが200または304が帰ってくることを確認
  • content-typeがjson形式になっていること
スクショ

スクリーンショット 2026-01-08 18 43 56
スクリーンショット 2026-01-08 18 51 38

どのユーザーでもOK

定期イベント

RegularEvents.jsx
  • regular_eventsのAPIレスポンスが200または304が帰ってくることを確認
  • content-typeがjson形式になっていること
スクショ

スクリーンショット 2026-01-08 18 44 46
スクリーンショット 2026-01-08 18 48 40

タグ入力

  • 各タグ入力・編集画面で共通のパーツなので代表して1画面で確認
TagsInput.jsx
  • tags.jsonのAPIレスポンスが200または304が帰ってくることを確認
スクショ

スクリーンショット 2025-12-15 18 03 47

tag.js
  • tags.jsonのAPIレスポンスが200または304が帰ってくることを確認
スクショ

スクリーンショット 2025-12-15 18 04 06

Screenshot

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

Summary by CodeRabbit

リリースノート

  • リファクタリング
    • 複数のコンポーネント間でデータ取得方式を統一し、アプリケーション全体の一貫性と保守性を向上させました。機能上の変更はありません。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 3, 2025

📝 Walkthrough

ウォークスルー

プロジェクト全体で使用されていた中央集約型の fetcher.js を削除し、Rails の @rails/request.js から get メソッドを直接インポートして、各コンポーネント内でローカルのフェッチャーを定義する置き換えを実施しました。既存の制御フローやエラーハンドリングは変わりません。

変更内容

コホート / ファイル 変更の概要
フェッチャー削除
app/javascript/fetcher.js
デフォルトエクスポート関数 fetcher(url) を削除。fetch を使用した単純な JSON 変換ロジックのみだった関数が廃止
コンポーネント内フェッチャー置き換え
app/javascript/components/BookmarksInDashboard.jsx, app/javascript/components/Events.jsx, app/javascript/components/NotificationsBell/NotificationsBell.jsx, app/javascript/components/Products.jsx, app/javascript/components/RegularEvents.jsx, app/javascript/components/Reports.jsx, app/javascript/components/Tags/TagsInput.jsx
@rails/request.js から get をインポート。ローカルフェッチャーを get(url, { responseKind: 'json' }).then((res) => res.json) で定義し、useSWR に渡すように変更
タグ関連モジュール置き換え
app/javascript/tag.js
フェッチャーからの import を削除し、@rails/request.js から get をインポート。fetchTagsData 内でデータ取得方式を新しい get API に変更

推定コードレビュー工数

🎯 2 (シンプル) | ⏱️ ~12 分

関連する可能性があるイシュー

  • 本 PR で fetcher.jsを撤廃したい #9257 に直接対応:プロジェクト全体の fetcher.js@rails/request.js に置き換える作業をメインで実装している

関連する可能性がある PR

  • タグ機能を非React化 #8881: app/javascript/tag.js を同じく古いフェッチャーから @rails/request.jsget に置き換えており、タグ関連コードの変更が重複している
  • 5つのjsファイルのfetchをrequest.jsに置き換える #8877: 同じくプロジェクト全体で fetch/fetcher の使用方法から @rails/request.js への移行を実施し、response.json() の呼び出し方式を置き換えている統一的な変更パターンとして関連している

推奨レビュアー

  • komagata
  • thmz337

🐰 古い fetcher よ、さらば!
Rails の request.js で新しい世界へ
ローカル get で軽やかに舞い
各地で統一の춤を踊る ✨
シンプルな変更、大きな改善!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは、fetcher.jsを廃止し@rails/request.jsに処理を統一するという主要な変更を明確に表現しており、変更セットの主要な目的と完全に関連している。
Description check ✅ Passed PRの説明はテンプレートの主要セクション(Issue、概要、変更確認方法)を含んでおり、修正内容、影響ファイル、実装方針が詳細に記載されています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@yokomaru yokomaru self-assigned this Dec 3, 2025
@yokomaru yokomaru marked this pull request as ready for review December 10, 2025 07:13
@github-actions github-actions Bot requested a review from komagata December 10, 2025 07:13
@yokomaru yokomaru force-pushed the chore/replace_fetcher_js_with_request_js branch from 0375a84 to 746c3bf Compare December 10, 2025 08:25
Copy link
Copy Markdown

@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/javascript/components/NotificationsBell/NotificationsBell.jsx (1)

8-8: fetcher の実装は正しいですが、クォートの統一を検討してください。

実装ロジックは正しく、Rails request.js の json getter を適切に使用しています(learnings に基づく)。ただし、このファイルでは "json" とダブルクォートを使用していますが、他のファイル(Bookmarks.jsx、Events.jsx、Notifications.jsx など)では 'json' とシングルクォートを使用しています。

Prettier が自動整形するため実害はありませんが、統一性の観点から他のファイルと揃えることをご検討ください。

必要に応じて以下の diff を適用できます:

-const fetcher = (url) => get(url, { responseKind: "json" }).then((res) => res.json)
+const fetcher = (url) => get(url, { responseKind: 'json' }).then((res) => res.json)
📜 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 0375a84 and 746c3bf.

📒 Files selected for processing (11)
  • app/javascript/components/Bookmarks.jsx (1 hunks)
  • app/javascript/components/BookmarksInDashboard.jsx (1 hunks)
  • app/javascript/components/Events.jsx (1 hunks)
  • app/javascript/components/Notifications.jsx (1 hunks)
  • app/javascript/components/NotificationsBell/NotificationsBell.jsx (1 hunks)
  • app/javascript/components/Products.jsx (1 hunks)
  • app/javascript/components/RegularEvents.jsx (1 hunks)
  • app/javascript/components/Reports.jsx (1 hunks)
  • app/javascript/components/Tags/TagsInput.jsx (1 hunks)
  • app/javascript/fetcher.js (0 hunks)
  • app/javascript/tag.js (2 hunks)
💤 Files with no reviewable changes (1)
  • app/javascript/fetcher.js
🚧 Files skipped from review as they are similar to previous changes (6)
  • app/javascript/components/Bookmarks.jsx
  • app/javascript/components/Tags/TagsInput.jsx
  • app/javascript/tag.js
  • app/javascript/components/Reports.jsx
  • app/javascript/components/Products.jsx
  • app/javascript/components/Events.jsx
🧰 Additional context used
📓 Path-based instructions (2)
app/**/*.{rb,js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Rails app code should be organized in app/ directory with subdirectories: models/, controllers/, views/, jobs/, helpers/, and frontend code under javascript/ (Shakapacker)

Files:

  • app/javascript/components/RegularEvents.jsx
  • app/javascript/components/NotificationsBell/NotificationsBell.jsx
  • app/javascript/components/BookmarksInDashboard.jsx
  • app/javascript/components/Notifications.jsx
app/javascript/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

JavaScript/TypeScript code in app/javascript/ should be linted with ESLint and formatted with Prettier via yarn lint scripts; use React 17 and Shakapacker/Webpack 5

Files:

  • app/javascript/components/RegularEvents.jsx
  • app/javascript/components/NotificationsBell/NotificationsBell.jsx
  • app/javascript/components/BookmarksInDashboard.jsx
  • app/javascript/components/Notifications.jsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 9331
File: app/javascript/action_completed_button.js:46-53
Timestamp: 2025-12-04T01:50:46.369Z
Learning: Rails request.js の FetchResponse クラスでは、HTTP ステータスコードは `response.statusCode` プロパティでアクセスする必要がある。`response.status` ではなく `response.statusCode` を使用する。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/watches.js:78-78
Timestamp: 2025-07-26T01:11:03.921Z
Learning: Rails request.jsのFetchResponseクラスでは、text、json、htmlプロパティはgetterとして定義されており、response.text()ではなくresponse.textとしてアクセスする必要がある。getterは自動的にレスポンスをキャッシュし、jsonの場合はContent-Typeの検証も行う。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-04T07:17:55.949Z
Learning: Rails request.jsのFetchResponseクラスでは、json、text、htmlなどはgetterとして定義されており、response.json()ではなくresponse.jsonとしてアクセスする必要がある。また、getterはContent-Typeの自動チェック機能を含んでいる。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。また、Content-Typeがapplication/jsonでない場合は自動的にエラーを投げる安全性チェックも含まれている。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/product.rb:59-61
Timestamp: 2025-09-11T14:47:53.256Z
Learning: Rails アップグレードPRでは、アップグレードに直接関連しない性能改善や機能追加の提案は避けるべき。PRのスコープを維持することが重要で、そのような改善提案は別PRで対応すべきである。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-04T07:17:55.949Z
Learning: Rails request.jsのFetchResponseクラスでは、jsonとtextはgetterとして定義されており、それぞれPromiseを返す。jsongetterは自動的にContent-Typeをチェックし、application/jsonでない場合はエラーを投げる。また、レスポンスは一度パースされるとキャッシュされる仕組みになっている。
📚 Learning: 2025-07-04T07:15:17.639Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。

Applied to files:

  • app/javascript/components/RegularEvents.jsx
📚 Learning: 2025-11-17T00:46:30.794Z
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。

Applied to files:

  • app/javascript/components/BookmarksInDashboard.jsx
🧬 Code graph analysis (3)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (8)
app/javascript/components/Bookmarks.jsx (1)
  • fetcher (8-9)
app/javascript/components/BookmarksInDashboard.jsx (1)
  • fetcher (7-8)
app/javascript/components/Events.jsx (1)
  • fetcher (8-9)
app/javascript/components/Notifications.jsx (1)
  • fetcher (9-10)
app/javascript/components/Products.jsx (1)
  • fetcher (10-11)
app/javascript/components/RegularEvents.jsx (1)
  • fetcher (9-10)
app/javascript/components/Reports.jsx (1)
  • fetcher (10-11)
app/javascript/components/Tags/TagsInput.jsx (1)
  • fetcher (10-10)
app/javascript/components/BookmarksInDashboard.jsx (8)
app/javascript/components/Bookmarks.jsx (1)
  • fetcher (8-9)
app/javascript/components/Events.jsx (1)
  • fetcher (8-9)
app/javascript/components/Notifications.jsx (1)
  • fetcher (9-10)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (1)
  • fetcher (8-8)
app/javascript/components/Products.jsx (1)
  • fetcher (10-11)
app/javascript/components/RegularEvents.jsx (1)
  • fetcher (9-10)
app/javascript/components/Reports.jsx (1)
  • fetcher (10-11)
app/javascript/components/Tags/TagsInput.jsx (1)
  • fetcher (10-10)
app/javascript/components/Notifications.jsx (8)
app/javascript/components/Bookmarks.jsx (1)
  • fetcher (8-9)
app/javascript/components/BookmarksInDashboard.jsx (1)
  • fetcher (7-8)
app/javascript/components/Events.jsx (1)
  • fetcher (8-9)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (1)
  • fetcher (8-8)
app/javascript/components/Products.jsx (1)
  • fetcher (10-11)
app/javascript/components/RegularEvents.jsx (1)
  • fetcher (9-10)
app/javascript/components/Reports.jsx (1)
  • fetcher (10-11)
app/javascript/components/Tags/TagsInput.jsx (1)
  • fetcher (10-10)
⏰ 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 (4)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (1)

7-7: LGTM: @rails/request.js の import が正しく追加されています。

このPR全体で統一されたパターンに従っており、問題ありません。

app/javascript/components/RegularEvents.jsx (1)

3-10: Rails request.js を使った fetcher への置き換えは妥当そうです

  • get(url, { responseKind: 'json' }).then((res) => res.json) で JSON を返す実装になっており、useSWR の fetcher として問題なさそうです。
  • res.json をメソッドではなくプロパティとして参照しているのも、Rails request.js の json が getter という過去の知見と一致しています(response.json() ではなく response.json)。retrieved_learnings の方針どおりです。
app/javascript/components/Notifications.jsx (1)

7-10: Notifications の fetcher 差し替えも他コンポーネントと揃っていて問題なさそうです

  • get の導入と const fetcher = (url) => get(url, { responseKind: 'json' }).then((res) => res.json) という実装は、他のコンポーネント(Bookmarks, Events など)と完全に同じ形で、SWR 用の fetcher として妥当だと思います。
  • Rails request.js の json getter を res.json として扱っている点も、既存のプロジェクト方針・過去の PR の learnings と整合しています。
app/javascript/components/BookmarksInDashboard.jsx (1)

3-8: Dashboard 用ブックマークの fetcher 置き換えと import 追加も問題なさそうです

  • get を追加して const fetcher = (url) => get(url, { responseKind: 'json' }).then((res) => res.json) としている点は、他コンポーネントと同じパターンで、Rails request.js の json getter の使い方としても正しいと思います。
  • useSWR(bookmarksUrl, fetcher)mutate(bookmarksUrl) で同じキーを使っており、削除後の再フェッチもこれまでどおり動作しそうです。
  • BookmarksInDashboard.jsx 自体は将来的に削除予定(retrieved_learnings)なので、この PR で過度に抽象化せず最小限の差し替えに留めているのもスコープ的に良さそうです。

@yokomaru yokomaru force-pushed the chore/replace_fetcher_js_with_request_js branch 2 times, most recently from 9736834 to 53c447a Compare December 10, 2025 14:21
Copy link
Copy Markdown

@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/javascript/tag.js (1)

3-64: タグ候補取得の request.js への移行は正しく行われています

get('/api/tags.json?taggable_type=...', { responseKind: 'json' }) のレスポンスに対して await response.json としており、request.js の FetchResponse.json を getter として扱う正しい形になっています。tagify.whitelist への代入ロジックも既存挙動と同等に見えます。

なお、同ファイル内の PUT /api/... は依然として素の fetch を使っているため、将来的にはこちらも request.js に統一するとコードスタイルとコーディングガイドラインの整合性がより高まりそうです(この PR では現状のままでも良さそうです)。As per coding guidelines, ...

📜 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 9736834 and 53c447a.

📒 Files selected for processing (11)
  • app/javascript/components/Bookmarks.jsx (1 hunks)
  • app/javascript/components/BookmarksInDashboard.jsx (1 hunks)
  • app/javascript/components/Events.jsx (1 hunks)
  • app/javascript/components/Notifications.jsx (1 hunks)
  • app/javascript/components/NotificationsBell/NotificationsBell.jsx (1 hunks)
  • app/javascript/components/Products.jsx (1 hunks)
  • app/javascript/components/RegularEvents.jsx (1 hunks)
  • app/javascript/components/Reports.jsx (1 hunks)
  • app/javascript/components/Tags/TagsInput.jsx (1 hunks)
  • app/javascript/fetcher.js (0 hunks)
  • app/javascript/tag.js (2 hunks)
💤 Files with no reviewable changes (1)
  • app/javascript/fetcher.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/javascript/components/Bookmarks.jsx
  • app/javascript/components/NotificationsBell/NotificationsBell.jsx
  • app/javascript/components/RegularEvents.jsx
  • app/javascript/components/Tags/TagsInput.jsx
🧰 Additional context used
📓 Path-based instructions (3)
app/**/*.{rb,js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Rails app code should be organized in app/ directory with subdirectories: models/, controllers/, views/, jobs/, helpers/, and frontend code under javascript/ (Shakapacker)

Files:

  • app/javascript/components/Products.jsx
  • app/javascript/components/Events.jsx
  • app/javascript/components/Notifications.jsx
  • app/javascript/components/Reports.jsx
  • app/javascript/tag.js
  • app/javascript/components/BookmarksInDashboard.jsx
app/javascript/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

JavaScript/TypeScript code in app/javascript/ should be linted with ESLint and formatted with Prettier via yarn lint scripts; use React 17 and Shakapacker/Webpack 5

Files:

  • app/javascript/components/Products.jsx
  • app/javascript/components/Events.jsx
  • app/javascript/components/Notifications.jsx
  • app/javascript/components/Reports.jsx
  • app/javascript/tag.js
  • app/javascript/components/BookmarksInDashboard.jsx
**/*.js

⚙️ CodeRabbit configuration file

**/*.js: - どうしても避けられない時以外に新規にVue.js, Reactのコードを追加しない。

  • fetchメソッドの代わりにrequest.jsを使う。

Files:

  • app/javascript/tag.js
🧠 Learnings (6)
📓 Common learnings
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 9331
File: app/javascript/action_completed_button.js:46-53
Timestamp: 2025-12-04T01:50:46.369Z
Learning: Rails request.js の FetchResponse クラスでは、HTTP ステータスコードは `response.statusCode` プロパティでアクセスする必要がある。`response.status` ではなく `response.statusCode` を使用する。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/watches.js:78-78
Timestamp: 2025-07-26T01:11:03.921Z
Learning: Rails request.jsのFetchResponseクラスでは、text、json、htmlプロパティはgetterとして定義されており、response.text()ではなくresponse.textとしてアクセスする必要がある。getterは自動的にレスポンスをキャッシュし、jsonの場合はContent-Typeの検証も行う。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/product.rb:59-61
Timestamp: 2025-09-11T14:47:53.256Z
Learning: Rails アップグレードPRでは、アップグレードに直接関連しない性能改善や機能追加の提案は避けるべき。PRのスコープを維持することが重要で、そのような改善提案は別PRで対応すべきである。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-04T07:17:55.949Z
Learning: Rails request.jsのFetchResponseクラスでは、json、text、htmlなどはgetterとして定義されており、response.json()ではなくresponse.jsonとしてアクセスする必要がある。また、getterはContent-Typeの自動チェック機能を含んでいる。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。また、Content-Typeがapplication/jsonでない場合は自動的にエラーを投げる安全性チェックも含まれている。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-04T07:17:55.949Z
Learning: Rails request.jsのFetchResponseクラスでは、jsonとtextはgetterとして定義されており、それぞれPromiseを返す。jsongetterは自動的にContent-Typeをチェックし、application/jsonでない場合はエラーを投げる。また、レスポンスは一度パースされるとキャッシュされる仕組みになっている。
📚 Learning: 2025-07-04T07:17:55.949Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-04T07:17:55.949Z
Learning: Rails request.jsのFetchResponseクラスでは、jsonとtextはgetterとして定義されており、それぞれPromiseを返す。jsongetterは自動的にContent-Typeをチェックし、application/jsonでない場合はエラーを投げる。また、レスポンスは一度パースされるとキャッシュされる仕組みになっている。

Applied to files:

  • app/javascript/tag.js
📚 Learning: 2025-07-26T01:11:03.921Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/watches.js:78-78
Timestamp: 2025-07-26T01:11:03.921Z
Learning: Rails request.jsのFetchResponseクラスでは、text、json、htmlプロパティはgetterとして定義されており、response.text()ではなくresponse.textとしてアクセスする必要がある。getterは自動的にレスポンスをキャッシュし、jsonの場合はContent-Typeの検証も行う。

Applied to files:

  • app/javascript/tag.js
📚 Learning: 2025-07-04T07:15:17.639Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。

Applied to files:

  • app/javascript/tag.js
📚 Learning: 2025-07-04T07:15:17.639Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 8877
File: app/javascript/check-stamp.js:22-24
Timestamp: 2025-07-04T07:15:17.639Z
Learning: Rails request.jsライブラリでは、FetchResponseクラスのjsonプロパティはgetterとして定義されており、response.json()ではなくresponse.jsonとして使用する必要がある。また、Content-Typeがapplication/jsonでない場合は自動的にエラーを投げる安全性チェックも含まれている。

Applied to files:

  • app/javascript/tag.js
📚 Learning: 2025-11-17T00:46:30.794Z
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。

Applied to files:

  • app/javascript/components/BookmarksInDashboard.jsx
🧬 Code graph analysis (2)
app/javascript/components/Reports.jsx (8)
app/javascript/components/Bookmarks.jsx (1)
  • fetcher (8-9)
app/javascript/components/BookmarksInDashboard.jsx (1)
  • fetcher (7-8)
app/javascript/components/Events.jsx (1)
  • fetcher (8-9)
app/javascript/components/Notifications.jsx (1)
  • fetcher (9-10)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (1)
  • fetcher (8-9)
app/javascript/components/Products.jsx (1)
  • fetcher (10-11)
app/javascript/components/RegularEvents.jsx (1)
  • fetcher (9-10)
app/javascript/components/Tags/TagsInput.jsx (1)
  • fetcher (10-11)
app/javascript/components/BookmarksInDashboard.jsx (8)
app/javascript/components/Bookmarks.jsx (1)
  • fetcher (8-9)
app/javascript/components/Events.jsx (1)
  • fetcher (8-9)
app/javascript/components/Notifications.jsx (1)
  • fetcher (9-10)
app/javascript/components/NotificationsBell/NotificationsBell.jsx (1)
  • fetcher (8-9)
app/javascript/components/Products.jsx (1)
  • fetcher (10-11)
app/javascript/components/RegularEvents.jsx (1)
  • fetcher (9-10)
app/javascript/components/Reports.jsx (1)
  • fetcher (10-11)
app/javascript/components/Tags/TagsInput.jsx (1)
  • fetcher (10-11)
⏰ 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 (5)
app/javascript/components/Products.jsx (1)

7-11: request.js を使った fetcher への置き換えは妥当です

get(url, { responseKind: 'json' }) に対して res.json をプロパティ参照しており、request.js の FetchResponse.json の仕様に沿った書き方になっています。既存の fetcher と同等の振る舞いになりそうで、特に懸念ありません。Based on learnings, ...

app/javascript/components/Events.jsx (1)

6-9: Events の fetcher 置き換えも一貫していて問題ありません

get の導入と const fetcher = (url) => get(url, { responseKind: 'json' }).then((res) => res.json) への差し替えは、他コンポーネントと同じパターンで、SWR の呼び出し側もそのままなので挙動は維持できていそうです。Based on learnings, ...

app/javascript/components/BookmarksInDashboard.jsx (1)

3-8: Dashboard 用ブックマークの取得も request.js ベースに正しく移行できています

get を使った fetcher の定義と、destroy の import 元を request.js に揃えたことで、取得・削除ともに同じライブラリに統一されており、SWR・mutate 周りのフローも従来どおり維持できていそうです。As per coding guidelines, ...

app/javascript/components/Notifications.jsx (1)

7-10: 通知一覧の fetcher 置き換えは SWR パターンと整合しています

apiUrl を SWR のキー関数として渡しつつ、fetcher を request.js ベースに差し替えており、res.json をプロパティとして扱う形も他ファイルと揃っているため、不整合はなさそうです。Based on learnings, ...

app/javascript/components/Reports.jsx (1)

3-11: 日報一覧の fetcher も request.js ベースに問題なく差し替えられています

get(url, { responseKind: 'json' }).then((res) => res.json) によるローカル fetcher 定義は、他コンポーネントと同じパターンで、request.js の json getter 仕様にも沿っているため、この置き換えによる挙動差はほぼなく安全そうです。Based on learnings, ...

@yokomaru yokomaru force-pushed the chore/replace_fetcher_js_with_request_js branch 2 times, most recently from a54833f to bf1cd7e Compare December 14, 2025 10:17
@yokomaru
Copy link
Copy Markdown
Contributor Author

@kutimiti1234

お疲れ様です!
もしご負担でなければレビューをお願いできますでしょうか?🙏
まったく急ぎではないのでお時間ある時で大丈夫ですっ!
年末でお忙しい中&検証数が多くて恐縮なのですが、ご検討いただけると幸いです🙇‍♀️

@yokomaru yokomaru force-pushed the chore/replace_fetcher_js_with_request_js branch from bf1cd7e to abdddb3 Compare December 28, 2025 03:53
@yokomaru
Copy link
Copy Markdown
Contributor Author

#9257 (comment)
以下は非React化対応はマージされたので、修正対象からは外してます。

@kutimiti1234
Copy link
Copy Markdown
Contributor

@yokomaru
こちらお返事できておらず大変申し訳ございません。
現状レビュー対応のほうがポイントとして多くなっていて、自身のPRをマージできていないため、大変申し訳ないのですが、今回は別の方にお願いできますでしょうか?

お待たせしていたにもかかわらず、大変申し訳ないのですが、以上よろしくお願いいたします。

@yokomaru
Copy link
Copy Markdown
Contributor Author

yokomaru commented Jan 8, 2026

@kutimiti1234
ご連絡ありがとうございます!承知しました!
現在レビューを依頼できる方が少なく、他の方も難しい場合は、ご自身のPRがマージされた後になっても問題ないので再度レビュー依頼をさせていただくかもしれません🙇‍♀️
お手数おかけいたしますがよろしくお願いいたします。

@yokomaru yokomaru requested review from karlley and tyrrell-IH and removed request for kutimiti1234 and tyrrell-IH January 8, 2026 03:55
@yokomaru
Copy link
Copy Markdown
Contributor Author

yokomaru commented Jan 8, 2026

@karlley
お疲れ様です!
こちらのPRにつきまして、レビューをお願いできますでしょうか?🙏(一応他のPRのレビューがないかも確認した上で依頼させていただいているのですが、見落としていたら申し訳ありません🙇‍♀️)
急ぎではないのでいつでも大丈夫です!
検証画面が多く恐縮なのですが、ご検討いただけると幸いです。

@karlley
Copy link
Copy Markdown
Contributor

karlley commented Jan 8, 2026

@yokomaru
お疲れ様です!
レビュー承知しました。
2週間ほどお時間いただきたいです。
よろしくお願いします!

@yokomaru
Copy link
Copy Markdown
Contributor Author

yokomaru commented Jan 8, 2026

@karlley
引き受けていただきありがとうございます!
期間につきましても承知いたしました〜!
よろしくお願いします!

Copy link
Copy Markdown
Contributor

@karlley karlley left a comment

Choose a reason for hiding this comment

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

@yokomaru
お待たせしました!
問題無さそうなのでApproveさせていただきます。

とても分かりやすいPRでレビューしやすく勉強になりました。
色々と真似させていただきます😄

@yokomaru
Copy link
Copy Markdown
Contributor Author

@karlley
ご返信遅れてしまい大変申し訳ありません!💦
ご確認いただきありがとうございます🙌

@komagata
メンバーレビューが完了いたしましたので、ご確認のほどよろしくお願いいたします。

Copy link
Copy Markdown
Member

@komagata komagata left a comment

Choose a reason for hiding this comment

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

確認させていただきました。OKです〜🙆‍♂️

@komagata komagata merged commit 8d27b2d into main Feb 7, 2026
28 checks passed
@komagata komagata deleted the chore/replace_fetcher_js_with_request_js branch February 7, 2026 10:54
@github-actions github-actions Bot mentioned this pull request Feb 7, 2026
11 tasks
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.

4 participants