@@ -294,12 +294,15 @@ export async function getActiveFlightByUsername(robloxUsername) {
294294}
295295
296296export async function storeTelemetryPoint ( flightId , { x, y, altitude, speed, heading, timestamp, phase, verticalSpeed } ) {
297+ // Ensure timestamp is in UTC to prevent timezone-related duplicates
298+ const utcTimestamp = timestamp instanceof Date ? timestamp . toISOString ( ) : timestamp ;
299+
297300 await pool . query ( `
298301 INSERT INTO logbook_telemetry (
299302 flight_id, timestamp, x, y, altitude_ft, speed_kts, heading, flight_phase, vertical_speed_fpm
300303 )
301- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
302- ` , [ flightId , timestamp , x , y , altitude , speed , heading , phase , verticalSpeed ?? 0 ] ) ;
304+ VALUES ($1, $2::timestamptz , $3, $4, $5, $6, $7, $8, $9)
305+ ` , [ flightId , utcTimestamp , x , y , altitude , speed , heading , phase , verticalSpeed ?? 0 ] ) ;
303306}
304307
305308export async function updateActiveFlightState ( robloxUsername , { altitude, speed, heading, x, y, phase } ) {
0 commit comments