Skip to content

fix: consider guaranteed interchange and max wait time when determining interchange possibility - #477

Merged
reidzeibel merged 1 commit into
mainfrom
ridwan/fix-add-guaranteed-interchange-into-account
Sep 2, 2026
Merged

fix: consider guaranteed interchange and max wait time when determining interchange possibility#477
reidzeibel merged 1 commit into
mainfrom
ridwan/fix-add-guaranteed-interchange-into-account

Conversation

@reidzeibel

@reidzeibel reidzeibel commented Sep 1, 2026

Copy link
Copy Markdown
Member

Similar to planner-web fix here, guaranteed interchange will now be taken into account when determining interchange possibility. Non-guaranteed interchanges will show the message as usual.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The current interchangeHolds logic can incorrectly suppress overlap detection for non-transit legs (e.g. foot legs), which may hide real timing inconsistencies.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates trip-status evaluation so that “impossible” is not triggered by timing overlaps at guaranteed interchanges, aligning backend behavior with planner-web and improving correctness of impossible-trip messaging.

Changes:

  • Extend hasTemporalOverlap to ignore overlaps when the relevant interchange is guaranteed (and still valid within maximumWaitTime when present).
  • Add helper functions to locate the prior transit leg and evaluate whether a guaranteed interchange still holds.
  • Add unit tests covering guaranteed/non-guaranteed interchanges, maximumWaitTime, and walk legs between transit legs; also cover determineTripStatus.
File summaries
File Description
src/service/impl/trips/utils.ts Adjusts temporal-overlap detection to account for guaranteed interchanges (with max-wait handling).
src/service/impl/trips/__tests__/utils.test.ts Adds test coverage for guaranteed interchange cases and trip-status behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +139 to +142
function interchangeHolds(legs: Leg[], index: number): boolean {
const interchange = previousTransitLeg(legs, index)?.interchangeTo;
if (interchange?.guaranteed !== true) return false;
if (interchange.maximumWaitTime == null) return true;

@gorandalum gorandalum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title should be more aligned with the changes, to make it easier to know if the right thing is implemented.

The title make it seem that guaranteed interchanges should never make trips impossible. But when looking at the code, it seems that if delay is greater than maxWaitTime, then the trip is impossible even if guaranteed interchange?

@reidzeibel reidzeibel changed the title fix: don't mark trips impossible on guaranteed interchange fix: consider guaranteed interchange and max wait time when determining interchange possibility Sep 2, 2026
@reidzeibel

Copy link
Copy Markdown
Member Author

@gorandalum changed the title and description

@gorandalum
gorandalum self-requested a review September 2, 2026 06:46
@reidzeibel
reidzeibel merged commit 5e5b7d8 into main Sep 2, 2026
2 checks passed
@reidzeibel
reidzeibel deleted the ridwan/fix-add-guaranteed-interchange-into-account branch September 2, 2026 07:20
@tormoseng

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants