|
@@ -21,26 +21,41 @@ export class PerformanceService {
|
|
private async updatePerformanceData(
|
|
private async updatePerformanceData(
|
|
performanceData: Record<string, any>,
|
|
performanceData: Record<string, any>,
|
|
version: SemanticVersionDto,
|
|
version: SemanticVersionDto,
|
|
- ): Promise<boolean> {
|
|
|
|
|
|
+ ): Promise<string[]> {
|
|
return this.performanceModel.deleteMany({}).then(async () => {
|
|
return this.performanceModel.deleteMany({}).then(async () => {
|
|
|
|
+ const invalidEntries: string[] = [];
|
|
|
|
+
|
|
for (const key in performanceData) {
|
|
for (const key in performanceData) {
|
|
if (key !== 'FILEINFO') {
|
|
if (key !== 'FILEINFO') {
|
|
- await this.performanceModel.create({
|
|
|
|
- icaoCode: key,
|
|
|
|
- aboveFL240: {
|
|
|
|
- speed: performanceData[key]['speedabovefl240'],
|
|
|
|
- rateOfDescend: performanceData[key]['rodabovefl240'],
|
|
|
|
- },
|
|
|
|
- aboveFL100: {
|
|
|
|
- speed: performanceData[key]['speedabovefl100'],
|
|
|
|
- rateOfDescend: performanceData[key]['rodabovefl100'],
|
|
|
|
- },
|
|
|
|
- belowFL100: {
|
|
|
|
- speed: performanceData[key]['speedbelowfl100'],
|
|
|
|
- rateOfDescend: performanceData[key]['rodbelowfl100'],
|
|
|
|
- },
|
|
|
|
- minimalApproachSpeed: performanceData[key]['speedapproach'],
|
|
|
|
- });
|
|
|
|
|
|
+ const validAircraft =
|
|
|
|
+ performanceData[key]['speedabovefl240'] !== undefined &&
|
|
|
|
+ performanceData[key]['rodabovefl240'] !== undefined &&
|
|
|
|
+ performanceData[key]['speedabovefl100'] !== undefined &&
|
|
|
|
+ performanceData[key]['rodabovefl100'] !== undefined &&
|
|
|
|
+ performanceData[key]['speedbelowfl100'] !== undefined &&
|
|
|
|
+ performanceData[key]['rodbelowfl100'] !== undefined &&
|
|
|
|
+ performanceData[key]['speedapproach'] !== undefined;
|
|
|
|
+
|
|
|
|
+ if (!validAircraft) {
|
|
|
|
+ invalidEntries.push(key);
|
|
|
|
+ } else {
|
|
|
|
+ await this.performanceModel.create({
|
|
|
|
+ icaoCode: key,
|
|
|
|
+ aboveFL240: {
|
|
|
|
+ speed: performanceData[key]['speedabovefl240'],
|
|
|
|
+ rateOfDescend: performanceData[key]['rodabovefl240'],
|
|
|
|
+ },
|
|
|
|
+ aboveFL100: {
|
|
|
|
+ speed: performanceData[key]['speedabovefl100'],
|
|
|
|
+ rateOfDescend: performanceData[key]['rodabovefl100'],
|
|
|
|
+ },
|
|
|
|
+ belowFL100: {
|
|
|
|
+ speed: performanceData[key]['speedbelowfl100'],
|
|
|
|
+ rateOfDescend: performanceData[key]['rodbelowfl100'],
|
|
|
|
+ },
|
|
|
|
+ minimalApproachSpeed: performanceData[key]['speedapproach'],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -50,15 +65,15 @@ export class PerformanceService {
|
|
version,
|
|
version,
|
|
);
|
|
);
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ return invalidEntries;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private async validateAndUpdatePerformanceData(): Promise<boolean> {
|
|
|
|
|
|
+ private async validateAndUpdatePerformanceData(): Promise<string[]> {
|
|
// read the performance file and validate the version length
|
|
// read the performance file and validate the version length
|
|
const data = PerformanceService.readPerformanceFile();
|
|
const data = PerformanceService.readPerformanceFile();
|
|
const versionParts = (data['FILEINFO']['version'] as string).split('.');
|
|
const versionParts = (data['FILEINFO']['version'] as string).split('.');
|
|
- if (versionParts.length !== 3) return false;
|
|
|
|
|
|
+ if (versionParts.length !== 3) return [];
|
|
|
|
|
|
// create the fileversion
|
|
// create the fileversion
|
|
const fileversion: SemanticVersionDto = {
|
|
const fileversion: SemanticVersionDto = {
|
|
@@ -84,7 +99,7 @@ export class PerformanceService {
|
|
return this.updatePerformanceData(data, fileversion);
|
|
return this.updatePerformanceData(data, fileversion);
|
|
}
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
|
|
|
+ return [];
|
|
})
|
|
})
|
|
.catch(() => this.updatePerformanceData(data, fileversion));
|
|
.catch(() => this.updatePerformanceData(data, fileversion));
|
|
}
|
|
}
|