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: ensure destination is last in formatSuggestedViasToRowVias() #8037

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

emersion
Copy link
Member

@emersion emersion commented Jul 12, 2024

See individual commits (some cleanups are also included).

See #8032 (comment)

Note, the first commit has been moved from #8032 to this PR to avoid merge conflicts.

@emersion
Copy link
Member Author

I tried isolating the logic in a function to avoid repetition, but ended up with something that was IMHO harder to read. (Maybe could have a function to do the findIndex() call?)

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2024

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

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 28.11%. Comparing base (4377935) to head (c9c1832).

Files Patch % Lines
front/src/modules/timesStops/utils.ts 0.00% 23 Missing ⚠️

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

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #8037      +/-   ##
============================================
- Coverage     28.12%   28.11%   -0.01%     
  Complexity     2112     2112              
============================================
  Files          1296     1296              
  Lines        158647   158659      +12     
  Branches       3164     3164              
============================================
- Hits          44614    44611       -3     
- Misses       112131   112146      +15     
  Partials       1902     1902              
Flag Coverage Δ
core 75.28% <ø> (ø)
editoast 70.36% <ø> (-0.02%) ⬇️
front 9.98% <0.00%> (-0.01%) ⬇️
gateway 2.03% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 73.18% <ø> (ø)

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.

(-1 || 0) is always evaluated to -1.

We want to move the OP to the start of the array if we find it.
If it's already at the start, the logic inside the conditional is
a no-op.
Instead of toSpliced() + unshift(), we can use array destructuring
to swap the first element with the one matching the origin.
The array has the type PathStep[], so not need to cast.
We were only handling the case where the path step is a UIC. Use
matchPathStepAndOp() so that we handle all other cases (track
offset, trigram, OP ID) correctly too.
Apply the same logic as the origin, but for the destination.

See #8032 (comment)
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

@SharglutDev SharglutDev added this pull request to the merge queue Jul 23, 2024
Merged via the queue into dev with commit dad4e39 Jul 23, 2024
20 checks passed
@SharglutDev SharglutDev deleted the emersion/reorder-dest-op branch July 23, 2024 09:42
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.

3 participants