Repository navigation
trainRouteクエリの設計変更に追従し、シミュレーション用の速度計算をサーバーへ委譲 - #6341
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough列車ルートの速度プロファイル生成を、固定定数ベースから GraphQL の ChangestrainRouteクエリへの移行
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant useSimulationMode
participant useGraphQLQuery
participant GraphQLServer
participant generateTrainSpeedProfile
useSimulationMode->>useGraphQLQuery: GET_TRAIN_ROUTE(fromStationId, toStationId, lineGroupId)
useGraphQLQuery->>GraphQLServer: trainRoute取得
GraphQLServer-->>useGraphQLQuery: trainRoute.segments
useGraphQLQuery-->>useSimulationMode: trainRouteData
useSimulationMode->>useSimulationMode: distanceFromPrevious を積算
useSimulationMode->>generateTrainSpeedProfile: maxSpeed/maxAcceleration/maxDeceleration
generateTrainSpeedProfile-->>useSimulationMode: 速度プロファイル
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…るSTAGING_API_URL未設定エラーを解消
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useSimulationMode.test.tsx (1)
72-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
mockStationは共通 factory に寄せられます。src/utils/test/factories.tsのcreateStationで置き換えられるので、ここではmockPassStationだけ通過駅用の派生として残し、setupAtomMocksはこのテスト固有のままで十分です。🤖 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/hooks/useSimulationMode.test.tsx` around lines 72 - 104, The test helper in useSimulationMode.test.tsx duplicates station construction logic that already exists in createStation, so replace mockStation usage with the shared factory from src/utils/test/factories.ts and keep only mockPassStation as the test-specific derived helper. Update the local setupAtomMocks/test setup to build stations through createStation for the common cases, preserving the existing line override behavior via the helper’s arguments rather than re-declaring the full Station shape.Source: Path instructions
🤖 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/useSimulationMode.ts`:
- Around line 81-95: `useSimulationMode` の `useGraphQLQuery(GET_TRAIN_ROUTE)` で
`trainRouteData` だけを受けており、失敗時の `error` が無視されています。`useSimulationMode` 内で
`error`(必要なら `loading` も)を分解して、クエリ失敗時にログ出力などで明示的に可視化してください。特に `trainRouteData`
を使う `useEffect` や `segments` 生成の前で、`useGraphQLQuery` の結果を見て失敗状態を追跡できるようにしてください。
In `@src/lib/graphql/queries.ts`:
- Around line 479-498: The GraphQL operation name in GET_TRAIN_ROUTE does not
follow the required FeatureVerbQuery naming pattern. Update the query name
inside the gql definition from GetTrainRoute to GetTrainRouteQuery so it matches
the coding guideline and stays consistent with other query names like
GetStationListQuery.
---
Outside diff comments:
In `@src/hooks/useSimulationMode.test.tsx`:
- Around line 72-104: The test helper in useSimulationMode.test.tsx duplicates
station construction logic that already exists in createStation, so replace
mockStation usage with the shared factory from src/utils/test/factories.ts and
keep only mockPassStation as the test-specific derived helper. Update the local
setupAtomMocks/test setup to build stations through createStation for the common
cases, preserving the existing line override behavior via the helper’s arguments
rather than re-declaring the full Station shape.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 61a8a12d-497e-4b29-8562-5d069ef22d44
📒 Files selected for processing (6)
src/@types/graphql.d.tssrc/constants/index.tssrc/constants/simulationMode.tssrc/hooks/useSimulationMode.test.tsxsrc/hooks/useSimulationMode.tssrc/lib/graphql/queries.ts
💤 Files with no reviewable changes (2)
- src/constants/simulationMode.ts
- src/constants/index.ts
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 2 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <[email protected]>
|
@coderabbitai approve |
✅ Action performedComments resolved and changes approved. |
概要
gql-stg.trainlcd.appのスキーマ変更(trainRouteクエリの引数fromStationGroupId/toStationGroupId→fromStationId/toStationIdへの改名)に追従し、あわせてuseSimulationModeの速度・加減速度・区間距離の算出を新設したGetTrainRouteクエリへ委譲しました。サーバー委譲により不要になった路線種別/列車種別ベースの定数テーブルは削除しています。変更の種類
変更内容
src/@types/graphql.d.tsを再生成(trainRouteの引数改名を反映)src/lib/graphql/queries.tsにGetTrainRouteクエリ(distanceFromPrevious/maxAcceleration/maxDeceleration/maxSpeed)を追加src/hooks/useSimulationMode.tsの速度プロファイル生成をGetTrainRouteの応答に委譲し、LINE_TYPE_MAX_ACCEL_IN_M_S等の路線種別/列車種別ベースの定数テーブルによる計算とgetDistanceを用いた直線距離計算を廃止segmentsは駅IDではなくmaybeRevsersedStationsと同じ並び順の配列位置で対応付け(同一駅IDが非隣接位置に複数回出現するケースでの誤対応を避けるため)src/constants/simulationMode.ts(路線種別/列車種別ベースの速度・加減速度定数)を削除src/hooks/useSimulationMode.test.tsxをuseGraphQLQueryのモックに合わせて全面的に書き直しテスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit