@@ -135,63 +135,15 @@ export async function putPilotIntoBlock(
135135 return await putPilotIntoBlock ( pilot , allPilots ) ;
136136}
137137
138- // Add this helper function after the imports, before determineInitialBlock
139-
140- async function calculatePositionBasedTTOT ( pilot : PilotDocument , allPilots : PilotDocument [ ] ) : Promise < Date > {
141- // Get pilots in the same block on the same runway
142- const pilotsInSameBlock = allPilots . filter (
143- ( plt ) =>
144- plt . flightplan . departure === pilot . flightplan . departure &&
145- plt . vacdm . block_rwy_designator === pilot . vacdm . block_rwy_designator &&
146- plt . vacdm . blockId === pilot . vacdm . blockId &&
147- plt . _id . toString ( ) !== pilot . _id . toString ( ) &&
148- ! plt . inactive
149- ) ;
150-
151- // Get runway capacity
152- const cap : AirportCapacity = await airportService . getCapacity (
153- pilot . flightplan . departure ,
154- pilot . vacdm . block_rwy_designator
155- ) ;
156-
157- // Calculate this pilot's position in the block (0-based)
158- const position = pilotsInSameBlock . length ;
159-
160- // Get block start time
161- const blockStartTime = blockUtils . getTimeFromBlock ( pilot . vacdm . blockId ) ;
162-
163- // Calculate increment: (position * 600 seconds) / capacity
164- const incrementSeconds = Math . floor ( ( position * 600 ) / cap . capacity ) ;
165-
166- // Apply increment to block start time
167- const ttot = new Date ( blockStartTime ) ;
168- ttot . setSeconds ( ttot . getSeconds ( ) + incrementSeconds ) ;
169-
170- // Ensure TTOT doesn't exceed block end (start + 10 minutes)
171- const blockEndTime = new Date ( blockStartTime ) ;
172- blockEndTime . setMinutes ( blockEndTime . getMinutes ( ) + 10 ) ;
173-
174- if ( ttot > blockEndTime ) {
175- // Cap at block end minus 30 seconds
176- ttot . setTime ( blockEndTime . getTime ( ) - 30000 ) ;
177- }
178-
179- return ttot ;
180- }
181-
182138async function setTime ( pilot : PilotDocument ) : Promise < {
183139 finalBlock : number ;
184140 finalTtot : Date ;
185141} > {
186- // Get all pilots for position calculation
187- const allPilots = await pilotService . getAllPilots ( { inactive : { $eq : false } } ) ;
188-
189142 if (
190143 pilot . vacdm . tsat > pilot . vacdm . tobt ||
191144 blockUtils . getBlockFromTime ( pilot . vacdm . ttot ) != pilot . vacdm . blockId
192145 ) {
193- // Use position-based TTOT calculation instead of just block start time
194- pilot . vacdm . ttot = await calculatePositionBasedTTOT ( pilot , allPilots ) ;
146+ pilot . vacdm . ttot = blockUtils . getTimeFromBlock ( pilot . vacdm . blockId ) ;
195147 pilot . vacdm . tsat = timeUtils . addMinutes (
196148 pilot . vacdm . ttot ,
197149 - pilot . vacdm . exot
@@ -203,7 +155,6 @@ async function setTime(pilot: PilotDocument): Promise<{
203155 pilot . vacdm . ttot = timeUtils . addMinutes ( pilot . vacdm . tsat , pilot . vacdm . exot ) ;
204156 }
205157
206- // CTOT override logic
207158 if ( ! timeUtils . isTimeEmpty ( pilot . vacdm . ctot ) ) {
208159 pilot . vacdm . blockId = blockUtils . getBlockFromTime ( pilot . vacdm . ctot ) ;
209160 pilot . vacdm . ttot = pilot . vacdm . ctot ;
0 commit comments