Repository navigation
環状区間の駅重複出現でETAの区間フィルタが無関係な出現を拾ってしまうバグを修正 - #6345
Conversation
leftStationsに1回しか出現しない駅(都庁前など)でも、区間内一致の再フィルタでは API側の無関係な重複出現まで拾い、後段のMap化で後勝ちして誤ったETA(例: 58分)が 表示されていたため、区間探索時に特定済みの一致インデックスを直接使うよう修正。
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughuseEstimateArrivalTimes フックの区間内停車駅絞り込みロジックが変更された。leftStations と allStops の対応インデックス(bestMatchedIndices)を新たに記録し、matchedStops をこのインデックスから直接構築することで、環状区間などでの同一駅重複出現による誤選択を防止する。対応するテストケースも追加された。 Changes重複駅混同修正
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Hook as useEstimateArrivalTimes
participant Window as 区間探索処理
participant Stops as matchedStops構築処理
Hook->>Window: leftStations[0]起点で最短区間を探索
Window->>Window: leftStations各要素のmatchedIndicesを記録
Window-->>Hook: windowStartIndex, bestMatchedIndices
alt windowStartIndex特定済み
Hook->>Stops: bestMatchedIndicesでallStopsから直接構築
else 特定不可
Hook->>Stops: groupId集合でwindowStopsをフィルタ
end
Stops-->>Hook: matchedStops
Hook->>Hook: relativeStops算出(相対化・currentStation除外)
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks/useEstimateArrivalTimes.ts (1)
183-190: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winフォールバック分岐で
visibleGroupIdsのSetが要素ごとに再生成されている。
filterのコールバック内でSetを構築しているため、windowStopsの各要素ごとにleftStations全体を走査してSetを作り直しており、計算量が O(stops × leftStations) になります。コールバック外へ巻き上げてください。♻️ 提案する修正
+ const visibleGroupIds = new Set(leftStations.map((ls) => ls.groupId)); const matchedStops = windowStartIndex !== -1 ? bestMatchedIndices.map((idx) => allStops[idx]) - : windowStops.filter((s) => { - const visibleGroupIds = new Set( - leftStations.map((ls) => ls.groupId) - ); - return ( - s.stationGroupId != null && visibleGroupIds.has(s.stationGroupId) - ); - }); + : windowStops.filter( + (s) => + s.stationGroupId != null && visibleGroupIds.has(s.stationGroupId) + );🤖 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/useEstimateArrivalTimes.ts` around lines 183 - 190, In the fallback branch of useEstimateArrivalTimes, the visibleGroupIds Set is being rebuilt inside the windowStops.filter callback for every stop, which causes repeated leftStations scans. Move the Set construction outside the filter callback so it is created once before filtering, then reuse it inside the predicate while keeping the existing stationGroupId membership check.
🤖 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.
Nitpick comments:
In `@src/hooks/useEstimateArrivalTimes.ts`:
- Around line 183-190: In the fallback branch of useEstimateArrivalTimes, the
visibleGroupIds Set is being rebuilt inside the windowStops.filter callback for
every stop, which causes repeated leftStations scans. Move the Set construction
outside the filter callback so it is created once before filtering, then reuse
it inside the predicate while keeping the existing stationGroupId membership
check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 334fc2fd-211d-44a9-ac14-a9e41d222201
📒 Files selected for processing (2)
src/hooks/useEstimateArrivalTimes.test.tsxsrc/hooks/useEstimateArrivalTimes.ts
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
概要
環状路線(都営大江戸線など)で同じ駅がETA APIのレスポンスに複数回出現する場合に、無関係な出現を誤って拾ってしまい、都庁前など特定の駅だけ大きく外れたETA(例: 58分)が表示される不具合を修正しました。
変更の種類
変更内容
useEstimateArrivalTimes.ts: leftStations とAPIレスポンス(allStops)の区間マッチングで、最良区間探索時に特定済みの一致インデックス(bestMatchedIndices)を直接使うよう変更。従来は区間内をstationGroupIdの集合一致で再フィルタしていたため、環状区間でAPI側に同じ駅が複数回出現すると無関係な出現まで拾ってしまい、LineBoard側のMap構築時に後勝ちで誤ったETAが残っていたuseEstimateArrivalTimes.test.tsx: leftStationsには1回しか出現しない駅が、API側の区間内では2回出現するケースを再現するリグレッションテストを追加テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit