Skip to content

Commit

Permalink
front: remove frequency labels in nge + ensure uniqueness
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Greiner <[email protected]>
  • Loading branch information
louisgreiner committed Jan 28, 2025
1 parent a35d7b5 commit 240a149
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const getNgeTrainruns = (state: MacroEditorState, labels: LabelDto[]) =>
let trainrunFrequency: TrainrunFrequency | undefined;
if (trainSchedule.labels) {
trainSchedule.labels.forEach((label) => {
if (label.includes('frequency')) {
if (!label.match(/^frequency::(?!30$|60$|120$)\d+$/)) {
const frequency = parseInt(label.split('::')[1], 10);
const trainrunFrequencyFound = DEFAULT_TRAINRUN_FREQUENCIES.find(
(freq) => freq.frequency === frequency
Expand All @@ -329,9 +329,11 @@ const getNgeTrainruns = (state: MacroEditorState, labels: LabelDto[]) =>
categoryId: DEFAULT_TRAINRUN_CATEGORY.id,
frequencyId: trainrunFrequency?.id || DEFAULT_TRAINRUN_FREQUENCY.id,
trainrunTimeCategoryId: DEFAULT_TRAINRUN_TIME_CATEGORY.id,
labelIds: (trainSchedule.labels || []).map((l) =>
labels.findIndex((e) => e.label === l && e.labelGroupId === TRAINRUN_LABEL_GROUP.id)
),
labelIds: (trainSchedule.labels || [])
.filter((l) => l.match(/^frequency::(?!30$|60$|120$)\d+$/))
.map((l) =>
labels.findIndex((e) => e.label === l && e.labelGroupId === TRAINRUN_LABEL_GROUP.id)
),
};
});

Expand Down

0 comments on commit 240a149

Please sign in to comment.