Skip to content

front: hourly timetable adapt nge - #17973

Open
Wadjetz wants to merge 1 commit into
devfrom
ebe/front/hourly-timetable-adapt-nge
Open

front: hourly timetable adapt nge#17973
Wadjetz wants to merge 1 commit into
devfrom
ebe/front/hourly-timetable-adapt-nge

Conversation

@Wadjetz

@Wadjetz Wadjetz commented Aug 3, 2026

Copy link
Copy Markdown
Member

close #17634

@Wadjetz Wadjetz self-assigned this Aug 3, 2026
@github-actions github-actions Bot added the area:front Work on Standard OSRD Interface modules label Aug 3, 2026
@Wadjetz
Wadjetz requested a review from emersion August 3, 2026 20:27
@Wadjetz
Wadjetz marked this pull request as ready for review August 3, 2026 20:27
@Wadjetz
Wadjetz requested a review from a team as a code owner August 3, 2026 20:27
@Wadjetz
Wadjetz requested a review from achrafmohye August 4, 2026 12:12
@maelysLeratRosso maelysLeratRosso moved this to Awaiting merge in Board PI 21 Aug 6, 2026

@emersion emersion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here are a few comments. Note, I haven't fully reviewed the PR yet.

)
return null;
const offset = timeLock.consecutiveTime - startTimeLock.consecutiveTime;
return new Date(startDate.getTime() + offset * 60 * 1000);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, no more manual duration manipulation! :)

// eslint-disable-next-line import/extensions
import duration from 'dayjs/plugin/duration.js';

import type { TimetableType } from 'common/api/osrdEditoastApi';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not a fan of "tainting" duration helpers with something specific to operational studies. Can we find a better home for this function?

* Elapsed time between two start times of the same kind. The result is a Duration in both
* cases: an elapsed time is an elapsed time, whatever the reference the operands count from.
*/
export const subtractStartTimes = (a: StartTime, b: StartTime) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This allows subtracting a Date from a Duration, and the other way around. Can we check that both values have the same type?

): T => {
if (timetableType !== 'HOURLY' || !paced) return pathAndSchedule;
const intervalMs = Duration.parse(paced.interval).ms;
if (intervalMs <= 0) return pathAndSchedule;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should never happen.

* Taking the offset modulo the interval designates the very same occurrence: with a train
* every 30 min, departing at :59 and departing at :29 are the same train.
*/
export const clampOffsetToInterval = <T extends { start_time: number }>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we fold this (keeping a comment explaining the reasoning) inside calculateStartTime()? It seems easy to forget to call this function. This would also remove the unnecessary generic.

});

describe('generatePathAndSchedule', () => {
test.each(FIXTURES)('hourly timetable: ngeToOsrd-inputDto-$0', async (name) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems weird to have a kind of generic test which does the same checks across random trainruns. Test should be "dumb", with hardcoded values.

Can't we instead pick a single trainrun, and check that the start_time is what we expect?

@emersion
emersion self-requested a review August 7, 2026 15:02
@emersion

Copy link
Copy Markdown
Member

I've introduced a bunch of helpers in #18076 which overlap with this PR's.

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

Status: Awaiting merge

Development

Successfully merging this pull request may close these issues.

System hour: Adapt NGE

4 participants