Skip to content

front: fix stopsCount for train schedules#15287

Merged
hhirtz merged 3 commits intodevfrom
uber/stop
Feb 19, 2026
Merged

front: fix stopsCount for train schedules#15287
hhirtz merged 3 commits intodevfrom
uber/stop

Conversation

@hhirtz
Copy link
Copy Markdown
Member

@hhirtz hhirtz commented Feb 17, 2026

The previous computation wasn't working in the following cases:

  • the train has no stops (because of the +1 at the end)
  • the train has several 0s stops (because it filters stops that last zero seconds)

This commit copies the stopsCount computation for paced trains here:

stopsCount: correspondingException?.path_and_schedule
? correspondingException.path_and_schedule.schedule.filter((step) => step.stop_for).length
: stopsCount,

This commit also adds stopsCount_zero translation entries, otherwise train schedules with zero stops shows up as having one stop.

Solves a part of this issue: #12372
The other part is solved by: #15290

How to test

Example timetable on small infra:
timetable(14).json

Without this change, train schedules that have no stops, train schedules that have several zero-second stops and train schedules that have one zero-second stop at the end all show up as having one stop if you click on the "show more details" button at the top of the TS list.

With this change, the correct stop count should be shown for all train schedules.

@github-actions github-actions Bot added the area:front Work on Standard OSRD Interface modules label Feb 17, 2026
Signed-off-by: Hubert Hirtz <hubert@hirtz.pm>
The previous computation wasn't working in the following cases:
- the train has no stops (because of the `+1` at the end)
- the train has several 0s stops (because it filters stops that last
  zero seconds)

This commit copies the `stopsCount` computation for paced trains here:
https://github.com/OpenRailAssociation/osrd/blob/c33666ef215468065858cf70036a01434cd52d9c/front/src/applications/operationalStudies/views/Scenario/components/Timetable/PacedTrain/hooks/useOccurrences.ts#L59-L61

This commit also adds `stopsCount_zero` translation entries, otherwise
train schedules with zero stops shows up as having one stop.

Solves a part of this issue:
#12372

Signed-off-by: Hubert Hirtz <hubert@hirtz.pm>
@hhirtz hhirtz marked this pull request as ready for review February 17, 2026 12:10
@hhirtz hhirtz requested a review from a team as a code owner February 17, 2026 12:10
@hhirtz hhirtz requested review from SharglutDev and Synar February 17, 2026 12:11
Comment thread front/public/locales/fr/operational-studies.json
@hhirtz hhirtz linked an issue Feb 17, 2026 that may be closed by this pull request
Copy link
Copy Markdown
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.

Thanks for the fix !

This subject led to a lot of discussions in the office !

The majority agrees that the destination (regardless if there is a stop 0 on it) should not be counted in the "stops" displayed in "more details".

Would you mind to make the correction ?

Copy link
Copy Markdown
Contributor

@Synar Synar left a comment

Choose a reason for hiding this comment

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

Sharglut's point notwithstanding, the code lgtm!

@hhirtz
Copy link
Copy Markdown
Member Author

hhirtz commented Feb 19, 2026

The majority agrees that the destination (regardless if there is a stop 0 on it) should not be counted in the "stops" displayed in "more details".

@SharglutDev How would you differentiate trains that don't stop at their destination? or is that something we don't care about?

will push the change either way

@hhirtz hhirtz requested a review from SharglutDev February 19, 2026 09:15
@SharglutDev
Copy link
Copy Markdown
Contributor

@SharglutDev How would you differentiate trains that don't stop at their destination? or is that something we don't care about?

Basically the stops displayed in "more details" should concern only the intermediate stops (to be iso with the round trip modal). So the destination should never be taken into account regardless if the train stops on it or not :)

Copy link
Copy Markdown
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, thanks for the last fix !

Since we changed the stop count behavior, you'll have to adapt the e2e test as well.

Comment thread front/src/applications/operationalStudies/utils.ts Outdated
Signed-off-by: Hubert Hirtz <hubert@hirtz.pm>
@hhirtz hhirtz requested a review from a team as a code owner February 19, 2026 11:14
@hhirtz hhirtz added this pull request to the merge queue Feb 19, 2026
Merged via the queue into dev with commit 8984301 Feb 19, 2026
29 checks passed
@hhirtz hhirtz deleted the uber/stop branch February 19, 2026 13:39
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.

Non consistent informations when a train doesn't stop at end

4 participants