diff --git a/backend/alembic/versions/002_local_flights.py b/backend/alembic/versions/002_local_flights.py index efee2ef..4c102c8 100644 --- a/backend/alembic/versions/002_local_flights.py +++ b/backend/alembic/versions/002_local_flights.py @@ -32,6 +32,7 @@ def upgrade() -> None: sa.Column('pob', sa.Integer(), nullable=False), sa.Column('flight_type', sa.Enum('LOCAL', 'CIRCUITS', 'DEPARTURE', name='localflighttype'), nullable=False), sa.Column('status', sa.Enum('BOOKED_OUT', 'DEPARTED', 'LANDED', 'CANCELLED', name='localflightstatus'), nullable=False, server_default='BOOKED_OUT'), + sa.Column('duration', sa.Integer(), nullable=True, comment='Duration in minutes'), sa.Column('notes', sa.Text(), nullable=True), sa.Column('created_dt', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.Column('etd', sa.DateTime(), nullable=True), diff --git a/backend/app/api/endpoints/public.py b/backend/app/api/endpoints/public.py index 3fa9ac4..06661d1 100644 --- a/backend/app/api/endpoints/public.py +++ b/backend/app/api/endpoints/public.py @@ -51,12 +51,18 @@ async def get_public_arrivals(db: Session = Depends(get_db)): # Only include flights booked out today if not (today_start <= flight.created_dt < today_end): continue + + # Calculate ETA from departed_dt + duration (if both are available) + eta = flight.departed_dt + if flight.departed_dt and flight.duration: + eta = flight.departed_dt + timedelta(minutes=flight.duration) + arrivals_list.append({ 'ac_call': flight.callsign or flight.registration, 'ac_reg': flight.registration, 'ac_type': flight.type, 'in_from': None, - 'eta': flight.departed_dt, + 'eta': eta, 'landed_dt': None, 'status': 'DEPARTED', 'isLocalFlight': True, diff --git a/backend/app/models/local_flight.py b/backend/app/models/local_flight.py index 9fb9ba3..3ea5e7f 100644 --- a/backend/app/models/local_flight.py +++ b/backend/app/models/local_flight.py @@ -27,6 +27,7 @@ class LocalFlight(Base): pob = Column(Integer, nullable=False) # Persons on board flight_type = Column(SQLEnum(LocalFlightType), nullable=False, index=True) status = Column(SQLEnum(LocalFlightStatus), nullable=False, default=LocalFlightStatus.BOOKED_OUT, index=True) + duration = Column(Integer, nullable=True) # Duration in minutes notes = Column(Text, nullable=True) created_dt = Column(DateTime, nullable=False, server_default=func.current_timestamp(), index=True) etd = Column(DateTime, nullable=True, index=True) # Estimated Time of Departure diff --git a/backend/app/schemas/local_flight.py b/backend/app/schemas/local_flight.py index d6d2e45..7b9fa64 100644 --- a/backend/app/schemas/local_flight.py +++ b/backend/app/schemas/local_flight.py @@ -23,6 +23,7 @@ class LocalFlightBase(BaseModel): callsign: Optional[str] = None pob: int flight_type: LocalFlightType + duration: Optional[int] = 45 # Duration in minutes, default 45 etd: Optional[datetime] = None # Estimated Time of Departure notes: Optional[str] = None @@ -57,6 +58,7 @@ class LocalFlightUpdate(BaseModel): callsign: Optional[str] = None pob: Optional[int] = None flight_type: Optional[LocalFlightType] = None + duration: Optional[int] = None status: Optional[LocalFlightStatus] = None etd: Optional[datetime] = None departed_dt: Optional[datetime] = None diff --git a/web/admin.html b/web/admin.html index 5ab6a40..d9d7e97 100644 --- a/web/admin.html +++ b/web/admin.html @@ -409,6 +409,10 @@ +