Explorar o código

optimize the performance table selection

Sven Czarnian %!s(int64=2) %!d(string=hai) anos
pai
achega
0bfd22a459
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      src/performance/performance.service.ts

+ 8 - 1
src/performance/performance.service.ts

@@ -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
       .findOne({ icaoCode: icao })
       .then(async (response) => {
@@ -178,6 +182,9 @@ export class PerformanceService {
             case 'L':
               return this.performanceModel.findOne({ icaoCode: 'C172' });
             case 'H':
+              if (engineCount === 2) {
+                return this.performanceModel.findOne({ icaoCode: 'B764' });
+              }
               return this.performanceModel.findOne({ icaoCode: 'B744' });
             case 'J':
               return this.performanceModel.findOne({ icaoCode: 'A388' });