optimize the performance table selection

This commit is contained in:
Sven Czarnian
2022-10-23 23:53:32 +02:00
parent 10818401e1
commit 0bfd22a459

View File

@@ -169,7 +169,11 @@ export class PerformanceService {
}); });
} }
async findAircraft(icao: string, wtc: string): Promise<Performance> { async findAircraft(
icao: string,
wtc: string,
engineCount: number,
): Promise<Performance> {
return this.performanceModel return this.performanceModel
.findOne({ icaoCode: icao }) .findOne({ icaoCode: icao })
.then(async (response) => { .then(async (response) => {
@@ -178,6 +182,9 @@ export class PerformanceService {
case 'L': case 'L':
return this.performanceModel.findOne({ icaoCode: 'C172' }); return this.performanceModel.findOne({ icaoCode: 'C172' });
case 'H': case 'H':
if (engineCount === 2) {
return this.performanceModel.findOne({ icaoCode: 'B764' });
}
return this.performanceModel.findOne({ icaoCode: 'B744' }); return this.performanceModel.findOne({ icaoCode: 'B744' });
case 'J': case 'J':
return this.performanceModel.findOne({ icaoCode: 'A388' }); return this.performanceModel.findOne({ icaoCode: 'A388' });