fix(block): reset distanceAlongBlock between configurations - #1428
Conversation
|
Warning Review limit reachedNext included review available in 21 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe block handler now resets ChangesBlock distance reset
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Block-stop distances now start at zero for each independent configuration while continuing to accumulate within that configuration. The targeted behavior is covered through the API route, with no remaining concrete merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
omlahore
left a comment
There was a problem hiding this comment.
Fix looks right to me. I ran the new test against the merge base and it fails there on the config 1 assertion, so it is a real regression test and not just a passing one.
One thing I noticed while checking it. The bug is visible through the fixture already, and on 25_1, which the tests above it are using. On the merge base /api/where/block/25_1 returns DistanceAlongBlock of 0 for the first configuration and 433750.77 for the first stop of the second one, and both go to 0 with your change. So I think an assertion through callAPIHandler would cover the same thing while also going through the real GetBlockDetails row shape, which the hand built rows kinda skip since they leave the arrival and departure fields at zero.
|
Thanks for the review! I’ve updated the regression test to use the existing 25_1 fixture and exercise the API through callAPIHandler, as suggested. It now verifies both the reset between configurations and accumulation within each configuration. The update is pushed to the PR. |
|
Test reads right to me now. I dropped the unused import locally and ran it against the merge base and it fails there with The build is red though. |
|
|
Thanks! I removed the unused gtfsdb import and pushed the cleanup in 5530963. The updated regression test passes, and all CI checks are now green. |



Summary
Fixes #1427. Resolves a bug in
transformBlockToEntrywhere theblockDistanceaccumulator was being erroneously carried across entirely distinct calendar configurations. This ensures that every newBlockConfigurationreturned by the/api/where/block/{id}.jsonendpoint accurately tracks its own geometric offsets beginning from0.0.Root Cause
The
var blockDistance float64accumulator was previously declared outside the iteration block overserviceIDs, meaning its value was never reset between independent service days.Fix
Scoped
var blockDistance float64directly into the individualserviceIDsiteration loop.Tests
Added
TestBlockHandlerCrossConfigurationDistanceResetto verify thatDistanceAlongBlockis strictly0.0at the first stop of independent configurations belonging to the same block entity, without harming the distance accumulations on contiguous trips within that block.Scope
This PR is narrowly focused to only address the cross-configuration
blockDistanceleak described in #1427. It intentionally does not address the broader trip ordering mechanisms or the distinct within-tripBlockSequenceincrementing behavior flagged in #1018.Summary by CodeRabbit
Bug Fixes
Tests