@@ -260,9 +260,10 @@ export function ensureCorrectFormat(data) {
260260 if ( ! Array . isArray ( data ) ) {
261261 // If it's already in the correct format, return it as is, BUT RE-CALCULATE TTL for grace period.
262262 if ( data && data . rawLogs && Array . isArray ( data . rawLogs ) ) {
263+ const calculatedTTL = calculateRetentionDate ( data . rawLogs ) ;
263264 return {
264265 ...data ,
265- retentionDate : calculateRetentionDate ( data . rawLogs ) ,
266+ retentionDate : data . retentionDate > calculatedTTL ? data . retentionDate : calculatedTTL ,
266267 APIKEY : data . APIKEY || DEFAULT_API_KEY ,
267268 } ;
268269 } else {
@@ -364,7 +365,7 @@ export function ensureCorrectFormat(data) {
364365 if ( ! hasPoints ) log ( "Bounds Calculation Failed: Could not find vehicle location data in any row." ) ;
365366
366367 // Calculate retention date using the helper
367- const retentionDateIdentifier = calculateRetentionDate ( logsArray ) ;
368+ const calculatedTTL = calculateRetentionDate ( logsArray ) ;
368369
369370 return {
370371 APIKEY : DEFAULT_API_KEY ,
@@ -374,7 +375,7 @@ export function ensureCorrectFormat(data) {
374375 solutionType : solutionType ,
375376 rawLogs : fullyNormalizedLogs ,
376377 bounds : hasPoints ? bounds : null ,
377- retentionDate : retentionDateIdentifier ,
378+ retentionDate : data . retentionDate > calculatedTTL ? data . retentionDate : calculatedTTL ,
378379 } ;
379380}
380381
0 commit comments