Skip to content

Commit

Permalink
fix: import 3rd party performance (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiAdrian authored Dec 10, 2024
1 parent add195a commit 5b0ecdc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/app/services/data/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ export class DataService implements OnDestroy {
);
}

insertCopyNetzgrafikDto(netzgrafikDto: NetzgrafikDto) {
insertCopyNetzgrafikDto(
netzgrafikDto: NetzgrafikDto,
enforceUpdate = true
) {
this.nodeService.unselectAllNodes();
const nodeMap = this.nodeService.mergeNodes(netzgrafikDto.nodes);
const trainrunMap = this.trainrunService.createNewTrainrunsFromDtoList(
Expand All @@ -124,15 +127,18 @@ export class DataService implements OnDestroy {
nodeMap,
trainrunMap,
netzgrafikDto.nodes,
enforceUpdate
);
this.nodeService.mergeLabelNode(netzgrafikDto, nodeMap);
this.nodeService.mergeConnections(
netzgrafikDto,
trainrunSectionMap,
nodeMap,
);
this.nodeService.connectionsUpdated();
this.nodeService.transitionsUpdated();
if (enforceUpdate) {
this.nodeService.connectionsUpdated();
this.nodeService.transitionsUpdated();
}
this.trainrunService.mergeLabelTrainrun(netzgrafikDto, trainrunMap);
this.noteService.createNewNoteFromDtoList(netzgrafikDto.freeFloatingTexts);
}
Expand Down
15 changes: 12 additions & 3 deletions src/app/services/data/trainrunsection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export class TrainrunSectionService implements OnDestroy {
nodeMap: Map<number, number>,
trainrunMap: Map<number, number>,
nodes: NodeDto[],
enforceUpdate = true
): Map<number, number> {
const trainrunSectionMap: Map<number, number> = new Map<number, number>();
trainrunSections.forEach((trainrunSection) => {
Expand All @@ -262,10 +263,13 @@ export class TrainrunSectionService implements OnDestroy {
nodeMap,
trainrunMap,
nodes,
enforceUpdate
);
trainrunSectionMap.set(trainrunSection.id, newTrainrunSection.getId());
});
this.trainrunSectionsUpdated();
if (enforceUpdate) {
this.trainrunSectionsUpdated();
}
return trainrunSectionMap;
}

Expand Down Expand Up @@ -1427,6 +1431,7 @@ export class TrainrunSectionService implements OnDestroy {
trainrunSection: TrainrunSection,
sourceIsNonStop = false,
targetIsNonStop = false,
enforceUpdate = true
) {
this.nodeService.addPortsToNodes(
sourceNode.getId(),
Expand All @@ -1440,8 +1445,10 @@ export class TrainrunSectionService implements OnDestroy {
sourceIsNonStop,
targetIsNonStop,
);
this.nodeService.nodesUpdated();
this.nodeService.transitionsUpdated();
if (enforceUpdate) {
this.nodeService.nodesUpdated();
this.nodeService.transitionsUpdated();
}
trainrunSection.routeEdgeAndPlaceText();
this.reRouteAffectedTrainrunSections(
sourceNode.getId(),
Expand All @@ -1454,6 +1461,7 @@ export class TrainrunSectionService implements OnDestroy {
nodeMap: Map<number, number>,
trainrunMap: Map<number, number>,
nodes: NodeDto[],
enforceUpdate = true
) {
const trainrunId = trainrunMap.get(trainrunSection.trainrunId);
const trainrun = this.trainrunService.getTrainrunFromId(trainrunId);
Expand Down Expand Up @@ -1490,6 +1498,7 @@ export class TrainrunSectionService implements OnDestroy {
newTrainrunSection,
sourceIsNonStop,
targetIsNonStop,
enforceUpdate
);
return newTrainrunSection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ export class EditorToolsViewComponent {
this.dataService.loadNetzgrafikDto(netzgrafikOnlyNodeDto);

// (Step 2) Import nodes and trainrunSectiosn by trainrun inseration (copy => create)
this.dataService.insertCopyNetzgrafikDto(netzgrafikDto);
this.dataService.insertCopyNetzgrafikDto(netzgrafikDto, false);

// step(3) Check whether a transitions object was given when not
// departureTime - arrivatelTime == 0 => non-stop
Expand Down

0 comments on commit 5b0ecdc

Please sign in to comment.