Public board for local fligts
This commit is contained in:
@@ -3,20 +3,95 @@ from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_db
|
||||
from app.crud.crud_ppr import ppr as crud_ppr
|
||||
from app.crud.crud_local_flight import local_flight as crud_local_flight
|
||||
from app.schemas.ppr import PPRPublic
|
||||
from app.models.local_flight import LocalFlightStatus
|
||||
from datetime import date
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/arrivals", response_model=List[PPRPublic])
|
||||
@router.get("/arrivals")
|
||||
async def get_public_arrivals(db: Session = Depends(get_db)):
|
||||
"""Get today's arrivals for public display"""
|
||||
"""Get today's arrivals for public display (PPR and local flights)"""
|
||||
arrivals = crud_ppr.get_arrivals_today(db)
|
||||
return arrivals
|
||||
|
||||
# Convert PPR arrivals to dictionaries
|
||||
arrivals_list = []
|
||||
for arrival in arrivals:
|
||||
arrivals_list.append({
|
||||
'ac_call': arrival.ac_call,
|
||||
'ac_reg': arrival.ac_reg,
|
||||
'ac_type': arrival.ac_type,
|
||||
'in_from': arrival.in_from,
|
||||
'eta': arrival.eta,
|
||||
'landed_dt': arrival.landed_dt,
|
||||
'status': arrival.status.value,
|
||||
'isLocalFlight': False
|
||||
})
|
||||
|
||||
# Add local flights with DEPARTED status
|
||||
local_flights = crud_local_flight.get_multi(
|
||||
db,
|
||||
status=LocalFlightStatus.DEPARTED,
|
||||
limit=1000
|
||||
)
|
||||
|
||||
# Convert local flights to match the PPR format for display
|
||||
for flight in local_flights:
|
||||
arrivals_list.append({
|
||||
'ac_call': flight.callsign or flight.registration,
|
||||
'ac_reg': flight.registration,
|
||||
'ac_type': flight.type,
|
||||
'in_from': None,
|
||||
'eta': flight.departure_dt,
|
||||
'landed_dt': None,
|
||||
'status': 'DEPARTED',
|
||||
'isLocalFlight': True,
|
||||
'flight_type': flight.flight_type.value
|
||||
})
|
||||
|
||||
return arrivals_list
|
||||
|
||||
|
||||
@router.get("/departures", response_model=List[PPRPublic])
|
||||
@router.get("/departures")
|
||||
async def get_public_departures(db: Session = Depends(get_db)):
|
||||
"""Get today's departures for public display"""
|
||||
"""Get today's departures for public display (PPR and local flights)"""
|
||||
departures = crud_ppr.get_departures_today(db)
|
||||
return departures
|
||||
|
||||
# Convert PPR departures to dictionaries
|
||||
departures_list = []
|
||||
for departure in departures:
|
||||
departures_list.append({
|
||||
'ac_call': departure.ac_call,
|
||||
'ac_reg': departure.ac_reg,
|
||||
'ac_type': departure.ac_type,
|
||||
'out_to': departure.out_to,
|
||||
'etd': departure.etd,
|
||||
'departed_dt': departure.departed_dt,
|
||||
'status': departure.status.value,
|
||||
'isLocalFlight': False
|
||||
})
|
||||
|
||||
# Add local flights with BOOKED_OUT status
|
||||
local_flights = crud_local_flight.get_multi(
|
||||
db,
|
||||
status=LocalFlightStatus.BOOKED_OUT,
|
||||
limit=1000
|
||||
)
|
||||
|
||||
# Convert local flights to match the PPR format for display
|
||||
for flight in local_flights:
|
||||
departures_list.append({
|
||||
'ac_call': flight.callsign or flight.registration,
|
||||
'ac_reg': flight.registration,
|
||||
'ac_type': flight.type,
|
||||
'out_to': None,
|
||||
'etd': flight.booked_out_dt,
|
||||
'departed_dt': None,
|
||||
'status': 'BOOKED_OUT',
|
||||
'isLocalFlight': True,
|
||||
'flight_type': flight.flight_type.value
|
||||
})
|
||||
|
||||
return departures_list
|
||||
Reference in New Issue
Block a user