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: fix opstudies itinary reversal dysfunctioning when times and margin where set #10438

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

Synar
Copy link
Contributor

@Synar Synar commented Jan 17, 2025

Close #10036 (🔆🔆🔆nicer one premium shiny pack🔆🔆🔆 version)

@Synar Synar requested a review from a team as a code owner January 17, 2025 19:24
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Jan 17, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.82%. Comparing base (9314f35) to head (e1d30a1).
Report is 85 commits behind head on dev.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #10438   +/-   ##
=======================================
  Coverage   81.82%   81.82%           
=======================================
  Files        1073     1074    +1     
  Lines      106829   106856   +27     
  Branches      730      735    +5     
=======================================
+ Hits        87413    87436   +23     
- Misses      19377    19381    +4     
  Partials       39       39           
Flag Coverage Δ
editoast 74.28% <ø> (-0.02%) ⬇️
front 89.35% <100.00%> (+<0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests 88.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Synar Synar requested review from emersion and achrafmohye January 20, 2025 13:16
Copy link
Contributor

@SharglutDev SharglutDev left a comment

Choose a reason for hiding this comment

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

Lgtm and tested, thank you for the shiny pack version 🔆🔆🔆

Copy link
Contributor

@achrafmohye achrafmohye left a comment

Choose a reason for hiding this comment

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

LGTM and tested 👍

@emersion
Copy link
Member

emersion commented Jan 27, 2025

I think we want to move the margin of each path step to the next path step before reversing. I think this version would be easier to follow:

const newPathSteps = pathSteps.map((step, index) => ({
  ...step,
  arrival: null,
  theoreticalMargin: pathSteps[index - 1]?.theoreticalMargin,
})).reverse();

Or am I missing something?

Would be nice to have tests for this.

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Dear GitHub, I've looked at this PR, now you can hide it from my review queue.

@Synar
Copy link
Contributor Author

Synar commented Jan 27, 2025

I think we want to move the margin of each path step to the next path step before reversing. I think this version would be easier to follow:

const newPathSteps = pathSteps.map((step, index) => ({
  ...step,
  arrival: null,
  theoreticalMargin: pathSteps[index - 1]?.theoreticalMargin,
})).reverse();

Or am I missing something?

Would be nice to have tests for this.

The issue is that a lot of intermediary path steps don't have a theoretical margins, and we should skip them when exchanging margins. So you should only set margins that were already set (plus start/end), the value to replace it with should be the last margin that was actually set, not simply the previous margin.

To give an example, [0%, undef, 3%, undef, undef, undef, 1%, undef] means we have 0% margin for 2 steps traveled, then 3% for 4, then 1% for 1.

So it should give first [undef, undef, 0%, undef, undef, undef, 3%, 1%] before reversing, then after [1%, 3%, undef, undef, undef, 0%, undef, undef] which is 1% for 1 step, 3% for 4, and 0% for 2. Same as the initial distrib, but reversed.

Your version would give [undef, 0%, undef, 3%, undef, undef, undef, 1%] then [1%, undef, undef, undef, 3%, undef, 0%, undef] so 1% for 4 steps, 3% for 2, and 0% for 1. Different from the initial distrib.

I will write a test ^^

@Synar Synar force-pushed the ali/fix-itinerary-reversal-in-op-studies branch 2 times, most recently from 30777ed to c05548e Compare January 27, 2025 21:18
@Synar
Copy link
Contributor Author

Synar commented Jan 27, 2025

@emersion I've added a couple tests ^^

@Synar Synar force-pushed the ali/fix-itinerary-reversal-in-op-studies branch from c05548e to de9a032 Compare January 27, 2025 21:30
@Synar Synar force-pushed the ali/fix-itinerary-reversal-in-op-studies branch from de9a032 to e1d30a1 Compare January 27, 2025 21:52
@emersion emersion self-requested a review January 28, 2025 15:53
@Synar Synar added this pull request to the merge queue Feb 5, 2025
Merged via the queue into dev with commit fde717c Feb 5, 2025
27 checks passed
@Synar Synar deleted the ali/fix-itinerary-reversal-in-op-studies branch February 5, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reversing the itinerary messes up the schedule points
5 participants