add a function to find the best performance table
This commit is contained in:
		| @@ -7,7 +7,7 @@ import { join } from 'path'; | ||||
| import { SemanticVersionDto } from '../versioning/dto/semanticversion.dto'; | ||||
| import { VersioningService } from '../versioning/versioning.service'; | ||||
| import { LoggingService } from '../logging/logging.service'; | ||||
| import { PerformanceDocument } from './models/performance.model'; | ||||
| import { PerformanceDocument, Performance } from './models/performance.model'; | ||||
|  | ||||
| const COMPONENT_NAME = 'performance'; | ||||
|  | ||||
| @@ -168,4 +168,25 @@ export class PerformanceService { | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   async findAircraft(icao: string, wtc: string): Promise<Performance> { | ||||
|     return this.performanceModel | ||||
|       .findOne({ icaoCode: icao }) | ||||
|       .then(async (response) => { | ||||
|         if (!response) { | ||||
|           switch (wtc) { | ||||
|             case 'L': | ||||
|               return this.performanceModel.findOne({ icaoCode: 'C172' }); | ||||
|             case 'H': | ||||
|               return this.performanceModel.findOne({ icaoCode: 'B744' }); | ||||
|             case 'J': | ||||
|               return this.performanceModel.findOne({ icaoCode: 'A388' }); | ||||
|             case 'M': | ||||
|             default: | ||||
|               return this.performanceModel.findOne({ icaoCode: 'A320' }); | ||||
|           } | ||||
|         } | ||||
|         return response; | ||||
|       }); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user