Major refactor WIP

This commit is contained in:
2026-04-03 11:13:44 -04:00
parent dee58e0aae
commit 7b2de645db
25 changed files with 5841 additions and 7760 deletions
+2
View File
@@ -17,6 +17,7 @@ class DepartureStatus(str, Enum):
DEPARTED = "DEPARTED"
LOCAL = "LOCAL"
CANCELLED = "CANCELLED"
PENDING = "PENDING"
class Departure(Base):
@@ -38,4 +39,5 @@ class Departure(Base):
created_by = Column(String(16), nullable=True, index=True)
submitted_via = Column(SQLEnum(SubmissionSource), nullable=False, default=SubmissionSource.ADMIN, index=True)
pilot_email = Column(String(128), nullable=True) # For public submissions
arrival_id = Column(BigInteger, nullable=True) # Linked arrival for PPR-activated departures
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
+37
View File
@@ -0,0 +1,37 @@
from sqlalchemy import Column, BigInteger, String, DateTime, Enum as SQLEnum, func, Index
from enum import Enum
from app.db.session import Base
class MovementType(str, Enum):
TAKEOFF = "TAKEOFF" # Aircraft becomes airborne
LANDING = "LANDING" # Aircraft touches down
OVERFLIGHT = "OVERFLIGHT" # Aircraft passes through airspace (e.g., on call or QSY)
GO_AROUND = "GO_AROUND" # Aircraft aborts landing and goes around
TOUCH_AND_GO = "TOUCH_AND_GO" # Aircraft lands and immediately takes off again
class Movement(Base):
__tablename__ = "movements"
id = Column(BigInteger, primary_key=True, autoincrement=True)
movement_type = Column(SQLEnum(MovementType), nullable=False, index=True)
aircraft_registration = Column(String(16), nullable=False, index=True)
aircraft_type = Column(String(32), nullable=True)
callsign = Column(String(16), nullable=True)
timestamp = Column(DateTime, nullable=False, index=True) # Exact time of movement
entity_type = Column(String(50), nullable=False, index=True) # PPR, LOCAL_FLIGHT, ARRIVAL, DEPARTURE, OVERFLIGHT
entity_id = Column(BigInteger, nullable=False, index=True) # ID of the associated flight record
to_location = Column(String(64), nullable=True) # Destination (TO) - populated based on movement type
from_location = Column(String(64), nullable=True) # Origin (FROM) - populated based on movement type
runway = Column(String(10), nullable=True) # Runway used (e.g., "10", "28", "04", "22")
wind = Column(String(20), nullable=True) # Wind speed/direction (e.g., "280/25")
pressure_setting = Column(String(20), nullable=True) # Pressure setting (e.g., "QNH1024", "QFE1013")
created_by = Column(String(16), nullable=True, index=True) # User who triggered the movement
ip_address = Column(String(45), nullable=True) # For audit
notes = Column(String(255), nullable=True) # Optional context (e.g., runway used)
created_at = Column(DateTime, nullable=False, server_default=func.current_timestamp())
# Composite index for efficient queries
__table_args__ = (
Index('idx_movement_lookup', 'entity_type', 'entity_id'),
Index('idx_movement_time', 'timestamp', 'movement_type'),
)
+1
View File
@@ -11,6 +11,7 @@ class PPRStatus(str, Enum):
LANDED = "LANDED"
DELETED = "DELETED"
DEPARTED = "DEPARTED"
ACTIVATED = "ACTIVATED"
class UserRole(str, Enum):