From 1e421c5473c55c396505f2971fab8d7f282b8c7e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 12 Nov 2024 09:48:31 +0100 Subject: [PATCH 1/2] front: drop outdated TODO and unnecessary ESLint comment The ESLint no-restricted-syntax lint has been disabled globally, and the TODO has been resolved when introducing getTrainrunSectionsByTrainrunId(). Signed-off-by: Simon Ser --- .../operationalStudies/components/MacroEditor/ngeToOsrd.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts b/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts index 5c431a9d04d..4a1c98645f3 100644 --- a/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts +++ b/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts @@ -55,7 +55,6 @@ const getTrainrunSectionsByTrainrunId = (netzgrafikDto: NetzgrafikDto, trainrunI // source port. let departureSection: TrainrunSectionDto | undefined; const sectionsByPrevTargetPortId = new Map(); - // eslint-disable-next-line no-restricted-syntax for (const section of sections) { const sourceNode = getNodeById(netzgrafikDto.nodes, section.sourceNodeId)!; const transition = sourceNode.transitions.find( @@ -177,7 +176,6 @@ const createTrainSchedulePayload = async ({ oldStartDate: Date; trainSchedule?: TrainScheduleBase; }) => { - // TODO: check that the trainrunSections format is still compatible const pathPromise = trainrunSections.map(async (section, index) => { const sourceNode = getNodeById(nodes, section.sourceNodeId); const targetNode = getNodeById(nodes, section.targetNodeId); From bf4a3d659f92f792666164514b77cd5ad1cb5e82 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 12 Nov 2024 10:28:31 +0100 Subject: [PATCH 2/2] =?UTF-8?q?front:=20handle=20non-stop=20transitions=20?= =?UTF-8?q?for=20NGE=20=E2=86=92=20OSRD=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Simon Ser --- .../components/MacroEditor/ngeToOsrd.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts b/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts index 4a1c98645f3..e09ffd1d9d4 100644 --- a/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts +++ b/front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts @@ -219,7 +219,12 @@ const createTrainSchedulePayload = async ({ const schedule = trainrunSections.flatMap((section, index) => { const nextSection = trainrunSections[index + 1]; - // TODO: extract isNonStopTransit from transitions + const node = getNodeById(nodes, section.targetNodeId)!; + const transition = node.transitions.find( + (tr) => tr.port1Id === section.targetPortId || tr.port2Id === section.targetPortId + ); + const isNonStopTransit = transition?.isNonStopTransit ?? false; + let arrival = getTimeLockDate(section.targetArrival, startTimeLock, startDate); const departure = nextSection ? getTimeLockDate(nextSection.sourceDeparture, startTimeLock, startDate) @@ -234,7 +239,7 @@ const createTrainSchedulePayload = async ({ return { at: `${section.targetNodeId}-${index + 1}`, arrival: formatDateDifference(arrival, startDate), - stop_for: departure ? formatDateDifference(departure, arrival) : null, + stop_for: departure && !isNonStopTransit ? formatDateDifference(departure, arrival) : null, }; });