11import { sendTelegramMessage , sendAdmin } from '../services/telegram'
22import { addFlightTracking , clearUserTracking , untrackFlight } from '../services/tracking'
3- import {
4- getFlightIdByNumberFromStatus ,
5- getNotTrackedFlightsFromStatus ,
6- generateFakeFlights ,
7- storeFlightsInStatus ,
8- } from '../services/flightData'
3+ import { getFlightIdByNumber , getNotTrackedFlights , generateFakeFlights , storeFlights } from '../services/flightData'
94import { getCurrentIdtTime , formatTimeAgo , formatTimestampForDisplay } from '../utils/dateTime'
105import { formatTrackingListOptimized , formatFlightSuggestions , escapeMarkdown } from '../utils/formatting'
116import { isValidFlightCode } from '../utils/validation'
@@ -133,7 +128,7 @@ export const handleCommand = async (request: Request, env: Env, ctx: DurableObje
133128 const results = [ ]
134129 for ( const code of flightCodes ) {
135130 if ( isValidFlightCode ( code ) ) {
136- const flightId = getFlightIdByNumberFromStatus ( code . toUpperCase ( ) . replace ( ' ' , '' ) , ctx )
131+ const flightId = getFlightIdByNumber ( code . toUpperCase ( ) . replace ( ' ' , '' ) , ctx )
137132 if ( flightId ) {
138133 addFlightTracking ( chatId , flightId , env , ctx )
139134 results . push ( `✓ Now tracking ${ code . toUpperCase ( ) } ` )
@@ -168,7 +163,7 @@ export const handleCommand = async (request: Request, env: Env, ctx: DurableObje
168163 const currentPage = parseInt ( cursorStr ) || 0
169164 const nextPage = currentPage + 1
170165
171- const eligibleFlights = getNotTrackedFlightsFromStatus ( chatId , ctx )
166+ const eligibleFlights = getNotTrackedFlights ( chatId , ctx )
172167 const startIndex = nextPage * 5
173168 const endIndex = startIndex + 5
174169 const pageFlights = eligibleFlights . slice ( startIndex , endIndex )
@@ -329,7 +324,7 @@ export const handleCommand = async (request: Request, env: Env, ctx: DurableObje
329324 } else if ( data === 'show_suggestions' ) {
330325 ctx . storage . kv . put ( `pagination_cursor_${ chatId } ` , '0' )
331326
332- const eligibleFlights = getNotTrackedFlightsFromStatus ( chatId , ctx )
327+ const eligibleFlights = getNotTrackedFlights ( chatId , ctx )
333328
334329 const { text, replyMarkup : suggestionsMarkup } = formatFlightSuggestions (
335330 eligibleFlights . slice ( 0 , 5 ) ,
@@ -366,7 +361,7 @@ export const handleCommand = async (request: Request, env: Env, ctx: DurableObje
366361 } else if ( data . startsWith ( 'suggestions_page:' ) ) {
367362 // Handle pagination
368363 const page = parseInt ( data . split ( ':' ) [ 1 ] )
369- const eligibleFlights = getNotTrackedFlightsFromStatus ( chatId , ctx )
364+ const eligibleFlights = getNotTrackedFlights ( chatId , ctx )
370365 const startIndex = page * 5
371366 const endIndex = startIndex + 5
372367 const pageFlights = eligibleFlights . slice ( startIndex , endIndex )
@@ -533,7 +528,7 @@ const handleTrack = async (chatId: number, text: string, env: Env, ctx: DurableO
533528 const results = [ ]
534529 for ( const code of flightCodes ) {
535530 if ( isValidFlightCode ( code ) ) {
536- const flightId = getFlightIdByNumberFromStatus ( code . toUpperCase ( ) . replace ( ' ' , '' ) , ctx )
531+ const flightId = getFlightIdByNumber ( code . toUpperCase ( ) . replace ( ' ' , '' ) , ctx )
537532 if ( flightId ) {
538533 addFlightTracking ( chatId , flightId , env , ctx )
539534 results . push ( `✓ Now tracking ${ code . toUpperCase ( ) } ` )
@@ -562,7 +557,7 @@ const handleClearTracked = async (chatId: number, env: Env, ctx: DurableObjectSt
562557}
563558
564559const handleTestTracking = async ( chatId : number , env : Env , ctx : DurableObjectState < DOProps > ) => {
565- const eligibleFlights = getNotTrackedFlightsFromStatus ( chatId , ctx )
560+ const eligibleFlights = getNotTrackedFlights ( chatId , ctx )
566561
567562 const { text, replyMarkup } = formatFlightSuggestions ( eligibleFlights . slice ( 0 , 5 ) , 0 , eligibleFlights . length , ctx )
568563 await sendTelegramMessage ( chatId , text , env , false , replyMarkup )
@@ -587,7 +582,7 @@ const handleTestData = async (chatId: number, env: Env, ctx: DurableObjectState<
587582 const fakeFlights = generateFakeFlights ( ctx )
588583
589584 // Store fake flights using new JSON approach (replaces SQLite storage)
590- storeFlightsInStatus ( fakeFlights , ctx )
585+ storeFlights ( fakeFlights , ctx )
591586
592587 await sendTelegramMessage (
593588 chatId ,
0 commit comments