経路検索で複数種別のConnectedRoutesを利用 - #6530
Conversation
📝 WalkthroughWalkthrough接続経路を取得するGraphQLクエリとデータ型を追加しました。経路の駅情報から列車種別を構築します。通常の列車種別がない場合は接続経路を使用し、駅情報を再利用して行き先選択状態を更新します。 Changes接続経路選択フロー
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant 行き先選択
participant GET_CONNECTED_ROUTES
participant buildConnectedRouteTrainType
行き先選択->>GET_CONNECTED_ROUTES: 出発駅グループIDと到着駅グループIDを送信
GET_CONNECTED_ROUTES-->>行き先選択: 接続経路と停車駅一覧を返却
行き先選択->>buildConnectedRouteTrainType: 接続経路を渡す
buildConnectedRouteTrainType-->>行き先選択: TrainTypeを返却
行き先選択->>行き先選択: 駅情報とモーダル状態を更新
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/lib/graphql/queries.ts (1)
482-485: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGraphQL 操作名を命名規約に合わせてください。
GetConnectedRoutesはFeatureVerbQuery形式ではありません。GetConnectedRoutesQueryのようにQuery接尾辞を追加してください。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/graphql/queries.ts` around lines 482 - 485, Update the GraphQL operation name in GetConnectedRoutes to follow the FeatureVerbQuery convention by adding the Query suffix, while preserving its variables and query body.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useDestinationSelection.ts`:
- Around line 196-255: Add integration tests for useDestinationSelection that
mock useLazyGraphQLQuery and call jest.clearAllMocks() after every test. Cover
that an existing single train type skips GET_CONNECTED_ROUTES, an empty
single-type result stores ConnectedRoutes stops and the virtual lineGroupId,
empty ConnectedRoutes preserves the existing line fallback, and switching to a
virtual candidate reuses cached stations without calling
GET_LINE_GROUP_STATIONS.
- Around line 196-204: Update the route-selection flow around fetchRouteTypes
and fetchConnectedRoutes to inspect each query result’s error before treating
its data as empty. Only invoke fetchConnectedRoutes when fetchRouteTypes
succeeded with no train types, and only apply the existing route fallback when
fetchConnectedRoutes succeeded with an empty response; propagate or handle
either fetch error instead of interpreting it as “no routes.”
---
Nitpick comments:
In `@src/lib/graphql/queries.ts`:
- Around line 482-485: Update the GraphQL operation name in GetConnectedRoutes
to follow the FeatureVerbQuery convention by adding the Query suffix, while
preserving its variables and query body.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 08b69967-f408-48b8-a3e0-ef152ba3162b
📒 Files selected for processing (4)
src/hooks/useDestinationSelection.tssrc/lib/graphql/queries.tssrc/utils/routeSearch.test.tssrc/utils/routeSearch.ts
概要
単一の列車種別だけでは到達できない経路を、ConnectedRoutesで検索できるようにします。
変更の種類
変更内容
routeTypesで単一種別の経路が見つからない場合のみconnectedRoutesを問い合わせます。lineGroupIdと駅列を保持し、初期候補と候補切替時に使用します。routeTypesまたはconnectedRoutesの取得失敗時は、経路なしとして次のフォールバックへ進まずエラー状態を維持します。GetConnectedRoutesQueryへ変更しました。lineGroupId、区間路線、区間種別の変換テストに加え、取得条件・状態更新・候補切替・取得失敗を検証するフック統合テストを追加して軽減します。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ることNode.js 22.23.2 / npm 10.9.9で以下を確認しました。
npm run lint: 605ファイルすべて通過npm test -- --runInBand: 202スイート、2,177テストすべて通過npm run typecheck: 通過npm test -- --runInBand src/hooks/useDestinationSelection.test.tsx: ConnectedRoutes選択フローの6テストすべて通過関連Issue
なし
スクリーンショット(任意)
UI変更なし
Summary by CodeRabbit
新機能
品質改善