Skip to content

Commit

Permalink
front: fix nge import when there is only one step
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainValls committed Dec 2, 2024
1 parent c98d385 commit 0c8842d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,16 @@ const importTimetable = async (
);
const trainSchedules = await trainSchedulesPromise.unwrap();

const filteredTrainSchedules = trainSchedules.filter(
(trainSchedule) => trainSchedule.path.length >= 2
);

const searchPayload = buildOpQuery(infraId, trainSchedules);
const searchResults = searchPayload ? await executeSearch(searchPayload, dispatch) : [];

const resource = {
id: 1,
capacity: trainSchedules.length,
capacity: filteredTrainSchedules.length,
};

const nodes: NodeDto[] = [];
Expand Down Expand Up @@ -300,7 +304,7 @@ const importTimetable = async (
const DTOLabels: LabelDto[] = [];
// Create one NGE train run per OSRD train schedule
let labelId = 0;
const trainruns: TrainrunDto[] = trainSchedules.map((trainSchedule) => {
const trainruns: TrainrunDto[] = filteredTrainSchedules.map((trainSchedule) => {
const formatedLabels: (LabelDto | undefined)[] = [];
let trainrunFrequency: TrainrunFrequency | undefined;
if (trainSchedule.labels) {
Expand Down Expand Up @@ -369,7 +373,7 @@ const importTimetable = async (

let trainrunSectionId = 0;
const nodesByOpId = new Map<string, NodeDto>();
const trainrunSections: TrainrunSectionDto[] = trainSchedules
const trainrunSections: TrainrunSectionDto[] = filteredTrainSchedules
.map((trainSchedule) => {
// Figure out the node ID for each path item
const pathNodeIds = trainSchedule.path.map((pathItem) => {
Expand Down

0 comments on commit 0c8842d

Please sign in to comment.