Repository navigation
ETAの駅突き合わせをstationGroupIdからstationIdに変更し環状区間の重複駅を確実に区別する - #6350
Conversation
leftStationsに1回しか出現しない駅(都庁前など)でも、区間内一致の再フィルタでは API側の無関係な重複出現まで拾い、後段のMap化で後勝ちして誤ったETA(例: 58分)が 表示されていたため、区間探索時に特定済みの一致インデックスを直接使うよう修正。
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
…reconciliation-977wq9
都庁前のように外回り/内回りでgroupIdは共通だがstationIdは別々に採番される駅があり、 groupIdベースの区間マッチングでは無関係な出現を拾って誤ったETAが残る余地があった。 stationIdは出現ごとに一意なため、これに切り替えることで曖昧さのない突き合わせにし、 複雑だった区間探索ロジックも不要になったため削除した。 Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
…reconciliation-977wq9
|
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 (2)
📝 WalkthroughWalkthrough到着予想到達時間の参照・算出キーをstationGroupIdからstationIdへ変更した。 ChangesstationGroupIdからstationIdへの到着推定キー移行
Estimated code review effort: 4 (Complex) | ~50 minutes 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: 1
🤖 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/components/LineBoardEast.tsx`:
- Around line 493-501: The stationId-based Map construction for estimated
minutes is duplicated across LineBoardEast, LineBoardJRKyushu, LineBoardSaikyo,
and LineBoardToei, so refactor it into a shared hook to avoid future drift.
Extract the current useMemo logic from estimatedMinutesByStationId into a
reusable helper such as useEstimatedMinutesByStationId, then replace each local
implementation with that shared hook while preserving the existing filtering and
stationId as number mapping behavior.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: af7a48de-174e-4b72-bf67-1ea08e696c7c
📒 Files selected for processing (6)
src/components/LineBoardEast.tsxsrc/components/LineBoardJRKyushu.tsxsrc/components/LineBoardSaikyo.tsxsrc/components/LineBoardToei.tsxsrc/hooks/useEstimateArrivalTimes.test.tsxsrc/hooks/useEstimateArrivalTimes.ts
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/components/LineBoardJRKyushu.test.tsx (1)
13-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winstationIdベースの値取得を検証するテストが未追加
LineBoardEast.test.tsxと同様に、
useEstimatedMinutesByStationIdのモックが常に空のMapを返すため、estimatedMinutesByStationId.get(s.id)がLineDotへ正しく伝播するケースが検証されていません。非空のMapを使ったテストケースの追加を推奨します。As per coding guidelines, "挙動を変更する際は、同じ変更セット内でテストも更新または追加すること".
🤖 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/components/LineBoardJRKyushu.test.tsx` around lines 13 - 21, Add a test case in LineBoardJRKyushu.test.tsx to cover stationId-based minute lookup propagation. The current mock for useEstimatedMinutesByStationId always returns an empty Map, so extend the setup to return a non-empty Map and assert that LineBoardJRKyushu passes estimatedMinutesByStationId.get(s.id) through to LineDot, similar to the coverage in LineBoardEast.test.tsx. Use the existing mocks for useEstimatedMinutesByStationId, LineBoardJRKyushu, and LineDot to locate and update the test.Source: Coding guidelines
src/components/LineBoardEast.test.tsx (1)
13-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winstationIdベースの値取得を検証するテストが未追加
useEstimatedMinutesByStationIdのモックが常に空のMapを返すため、既存テストはestimatedMinutesByStationId.get(s.id)がLineDotへ正しく伝播するケースを一切検証していません。本PRの主眼であるstationId移行の正しさを担保するため、非空のMapを返すモックを使い、LineDotが期待するestimatedMinutes値を受け取ることを確認するテストケースの追加を推奨します。As per coding guidelines, "挙動を変更する際は、同じ変更セット内でテストも更新または追加すること".
♻️ 追加テスト例
it('LineDotコンポーネントが各駅に対してレンダリングされる', () => { const { LineDot } = require('./LineBoard/shared/components'); render( <LineBoardEast stations={mockStations} lineColors={['`#9acd32`', '`#9acd32`']} hasTerminus={false} /> ); expect(LineDot).toHaveBeenCalled(); }); + + it('stationIdに対応するestimatedMinutesがLineDotへ渡される', () => { + const { useEstimatedMinutesByStationId } = require('~/hooks'); + useEstimatedMinutesByStationId.mockReturnValue(new Map([[2, 5]])); + const { LineDot } = require('./LineBoard/shared/components'); + render( + <LineBoardEast + stations={mockStations} + lineColors={['`#9acd32`', '`#9acd32`']} + hasTerminus={false} + /> + ); + expect(LineDot).toHaveBeenCalledWith( + expect.objectContaining({ estimatedMinutes: 5 }), + undefined + ); + });🤖 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/components/LineBoardEast.test.tsx` around lines 13 - 21, The current LineBoardEast tests never verify the stationId-based estimated minutes flow because useEstimatedMinutesByStationId is mocked to always return an empty Map. Update the test setup in LineBoardEast.test.tsx so useEstimatedMinutesByStationId can return a non-empty Map keyed by stationId, and add a case that asserts LineDot receives the expected estimatedMinutes from estimatedMinutesByStationId.get(s.id). Use the existing LineBoardEast and LineDot test paths to confirm the stationId migration is wired through correctly.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/index.ts`:
- Line 25: Add dedicated tests for useEstimatedMinutesByStationId to directly
cover its internal logic, since LineBoard tests mock the hook with jest.fn(() =>
new Map()) and won’t catch regressions. Focus the new tests on the hook’s
stationId filtering when stationId is null/undefined and on the
cumulativeMinutes-to-Map conversion behavior inside
useEstimatedMinutesByStationId, so the real hook implementation is exercised and
protected.
---
Outside diff comments:
In `@src/components/LineBoardEast.test.tsx`:
- Around line 13-21: The current LineBoardEast tests never verify the
stationId-based estimated minutes flow because useEstimatedMinutesByStationId is
mocked to always return an empty Map. Update the test setup in
LineBoardEast.test.tsx so useEstimatedMinutesByStationId can return a non-empty
Map keyed by stationId, and add a case that asserts LineDot receives the
expected estimatedMinutes from estimatedMinutesByStationId.get(s.id). Use the
existing LineBoardEast and LineDot test paths to confirm the stationId migration
is wired through correctly.
In `@src/components/LineBoardJRKyushu.test.tsx`:
- Around line 13-21: Add a test case in LineBoardJRKyushu.test.tsx to cover
stationId-based minute lookup propagation. The current mock for
useEstimatedMinutesByStationId always returns an empty Map, so extend the setup
to return a non-empty Map and assert that LineBoardJRKyushu passes
estimatedMinutesByStationId.get(s.id) through to LineDot, similar to the
coverage in LineBoardEast.test.tsx. Use the existing mocks for
useEstimatedMinutesByStationId, LineBoardJRKyushu, and LineDot to locate and
update the test.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: ab574539-89e7-412b-b81c-333618949092
📒 Files selected for processing (10)
src/components/LineBoardEast.test.tsxsrc/components/LineBoardEast.tsxsrc/components/LineBoardJRKyushu.test.tsxsrc/components/LineBoardJRKyushu.tsxsrc/components/LineBoardSaikyo.test.tsxsrc/components/LineBoardSaikyo.tsxsrc/components/LineBoardToei.test.tsxsrc/components/LineBoardToei.tsxsrc/hooks/index.tssrc/hooks/useEstimatedMinutesByStationId.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/components/LineBoardEast.test.tsx`:
- Around line 190-206: The mocked return value for
useEstimatedMinutesByStationId in LineBoardEast.test.tsx is leaking past this
test because afterEach only clears call history, not implementations. Update the
test around LineDot to use a one-time mock return (mockReturnValueOnce) or
explicitly restore the default empty Map afterward so the behavior stays
isolated to this case.
In `@src/components/LineBoardJRKyushu.test.tsx`:
- Around line 165-181: The test setup in LineBoardJRKyushu.test.tsx leaves the
mocked useEstimatedMinutesByStationId return value active beyond this case, so
update the mock in the LineDot assertion test to use a one-time return value
instead of a persistent one. Locate the test that requires
useEstimatedMinutesByStationId from ~/hooks and verifies LineDot, and change the
mock so only this scenario receives the Map([[2, 5]]) result while other tests
remain unaffected.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 89b211d3-eef8-4480-b999-a403f4ab43e9
📒 Files selected for processing (3)
src/components/LineBoardEast.test.tsxsrc/components/LineBoardJRKyushu.test.tsxsrc/hooks/useEstimatedMinutesByStationId.test.ts
…トに漏れないようmockReturnValueOnceに変更 Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
|
@coderabbitai approve |
✅ Action performedComments resolved and changes approved. |
概要
先行してマージ済みの #6345 では、環状区間(都営大江戸線など)でETA APIのレスポンスに同じ駅が複数回出現する場合の誤ったETA表示を、
stationGroupIdベースの区間探索アルゴリズムで対処していました。しかし都庁前の外回り/内回りのように、groupIdは共通でもstationIdは出現ごとに別々に採番されている駅があるため、groupIdベースのマッチングでは原理的に曖昧さが残っていました。本PRでは突き合わせキーを一意なstationIdに変更し、この曖昧さを根本的に解消します。変更の種類
変更内容
useEstimateArrivalTimes.ts: ETAの区間マッチングをstationGroupIdから一意なstationIdベースに変更。曖昧さがなくなったため、以前追加した複雑な区間探索(bestMatchedIndices)ロジックが不要になり削除、シンプルなfilterベースの実装に戻したLineBoardSaikyo/Toei/East/JRKyushu.tsx: ETA表示用のMap(estimatedMinutesByGroupId→estimatedMinutesByStationId)も同様にstationIdキーへ変更useEstimateArrivalTimes.test.tsx: 同一groupId・別stationIdの2出現(都庁前の外回り/内回り相当)がある場合に正しい出現だけを拾えることを検証するテストに書き直しテスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit