Public board fixes
This commit is contained in:
@@ -69,10 +69,14 @@ async def get_public_arrivals(db: Session = Depends(get_db)):
|
||||
# Only include BOOKED_IN and LANDED arrivals
|
||||
if arrival.status not in (ArrivalStatus.BOOKED_IN, ArrivalStatus.LANDED):
|
||||
continue
|
||||
# For BOOKED_IN, only include those from today; for LANDED, include all
|
||||
# For BOOKED_IN, only include those created today
|
||||
if arrival.status == ArrivalStatus.BOOKED_IN:
|
||||
if not (today_start <= arrival.created_dt < today_end):
|
||||
continue
|
||||
# For LANDED, only include those landed today
|
||||
elif arrival.status == ArrivalStatus.LANDED:
|
||||
if not arrival.landed_dt or not (today_start <= arrival.landed_dt < today_end):
|
||||
continue
|
||||
|
||||
arrivals_list.append({
|
||||
'registration': arrival.registration,
|
||||
@@ -145,8 +149,16 @@ async def get_public_departures(db: Session = Depends(get_db)):
|
||||
limit=1000
|
||||
)
|
||||
|
||||
# Get today's date boundaries
|
||||
today = date.today()
|
||||
today_start = datetime.combine(today, datetime.min.time())
|
||||
today_end = datetime.combine(today + timedelta(days=1), datetime.min.time())
|
||||
|
||||
# Convert departures to match the format for display
|
||||
for dep in departures_to_airports:
|
||||
# Only include departures booked out today
|
||||
if not (today_start <= dep.created_dt < today_end):
|
||||
continue
|
||||
departures_list.append({
|
||||
'ac_call': dep.callsign or dep.registration,
|
||||
'ac_reg': dep.registration,
|
||||
@@ -159,4 +171,27 @@ async def get_public_departures(db: Session = Depends(get_db)):
|
||||
'isDeparture': True
|
||||
})
|
||||
|
||||
# Add departures to other airports with DEPARTED status (taken off today)
|
||||
departed_to_airports = crud_departure.get_multi(
|
||||
db,
|
||||
status=DepartureStatus.DEPARTED,
|
||||
limit=1000
|
||||
)
|
||||
|
||||
for dep in departed_to_airports:
|
||||
# Only include departures that departed today
|
||||
if not dep.departed_dt or not (today_start <= dep.departed_dt < today_end):
|
||||
continue
|
||||
departures_list.append({
|
||||
'ac_call': dep.callsign or dep.registration,
|
||||
'ac_reg': dep.registration,
|
||||
'ac_type': dep.type,
|
||||
'out_to': dep.out_to,
|
||||
'etd': dep.etd or dep.created_dt,
|
||||
'departed_dt': dep.departed_dt,
|
||||
'status': 'DEPARTED',
|
||||
'isLocalFlight': False,
|
||||
'isDeparture': True
|
||||
})
|
||||
|
||||
return departures_list
|
||||
Reference in New Issue
Block a user