Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: simplify OP matching in updatePathStepsFromOperationalPoints() #9761

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

emersion
Copy link
Member

We already have a matchPathStepAndOp() function to compare a PathStep and a SuggestedOP. There are two differences:

  • The old code checks whether PathStep.ch is set before comparing it with SuggestedOP.ch, but that's incorrect. On the editoast side the secondary_code field is defined as Option<String>: None accepts OPs with any secondary code, "" accepts only OPs without any secondary code. On the TypeScript side, undefined accepts OPs with any secondary code, and '' accepts only OPs without any secondary code. However 'ch' in step is true for { ch: undefined }, which compares SuggestedOP.ch with undefined even if an undefined PathStep.ch is supposed to match any OP secondary code.
  • The old code checks PathStep.secondary_code. However the PathSteps given to updatePathStepsFromOperationalPoints() come straight up from computeBasePathSteps(), which always leaves secondary_code undefined. As a result we never hit this case.

@emersion emersion requested a review from a team as a code owner November 18, 2024 14:17
@emersion emersion force-pushed the emr/simplify-setup-itinerary-for-train-update branch 3 times, most recently from c0dcdcf to bed6c50 Compare November 18, 2024 15:09
Trains created via NGE don't have a secondary_code field in their
PathSteps passed to updatePathStepsFromOperationalPoints(). This
can be checked by creating a train in NGE, setting a rolling stock
for it, and then adding a console.log() right before the
updatePathStepsFromOperationalPoints() call. The ch field is
populated and the secondary_code field doesn't exist.

This is because all PathItemLocation entries are piped into
computeBasePathSteps(), which strips secondary_code regardless of
whether the path steps are defined in terms of UIC (by OSRD) or
trigram (by NGE).

Signed-off-by: Simon Ser <[email protected]>
We already have a matchPathStepAndOp() function to compare a PathStep
and a SuggestedOP. There are two differences:

- The old code checks whether PathStep.ch is set before comparing
  it with SuggestedOP, but that's incorrect. On the editoast side
  the secondary_code field is defined as Option<String>: None
  accepts OPs with any secondary code, "" accepts only OPs without
  any secondary code. On the TypeScript side, undefined accepts OPs
  with any secondary code, and '' accepts only OPs without any
  secondary code. However `'ch' in step` is true for
  `{ ch: undefined }`, which compares SuggestedOP.ch with undefined
  even if an undefined PathStep.ch is supposed to match any OP
  secondary code.
- The old code checks PathStep.secondary_code. However the PathSteps
  given to updatePathStepsFromOperationalPoints() come straight up
  from computeBasePathSteps(), which always leaves secondary_code
  undefined. As a result we never hit this case.

Signed-off-by: Simon Ser <[email protected]>
@emersion emersion force-pushed the emr/simplify-setup-itinerary-for-train-update branch from bed6c50 to ea909bf Compare November 18, 2024 16:35
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@emersion emersion added this pull request to the merge queue Nov 26, 2024
Merged via the queue into dev with commit e7ec4b0 Nov 26, 2024
27 checks passed
@emersion emersion deleted the emr/simplify-setup-itinerary-for-train-update branch November 26, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants