PPR ACK and Bulk Logging start

This commit is contained in:
2026-06-15 15:45:58 -04:00
parent 7b2de645db
commit 1952b89ecf
14 changed files with 1710 additions and 19 deletions
+32 -1
View File
@@ -47,6 +47,37 @@ class CRUDMovement:
db.refresh(db_obj)
return db_obj
def update(self, db: Session, db_obj: Movement, obj_in: MovementCreate) -> Movement:
update_data = obj_in.dict()
for field, value in update_data.items():
setattr(db_obj, field, value)
db.add(db_obj)
db.commit()
db.refresh(db_obj)
return db_obj
def find_daily_match(
self,
db: Session,
target_date: date,
aircraft_registration: str,
movement_type: MovementType,
entity_type: Optional[str] = None,
entity_types: Optional[List[str]] = None
) -> Optional[Movement]:
clean_reg = "".join(char for char in aircraft_registration.upper() if char.isalnum())
clean_column = func.upper(func.replace(func.replace(Movement.aircraft_registration, "-", ""), " ", ""))
query = db.query(Movement).filter(
func.date(Movement.timestamp) == target_date,
clean_column == clean_reg,
Movement.movement_type == movement_type
)
if entity_type:
query = query.filter(Movement.entity_type == entity_type)
if entity_types:
query = query.filter(Movement.entity_type.in_(entity_types))
return query.order_by(Movement.timestamp.desc()).first()
def get_movements_by_entity(self, db: Session, entity_type: str, entity_id: int) -> List[Movement]:
return db.query(Movement).filter(
and_(Movement.entity_type == entity_type, Movement.entity_id == entity_id)
@@ -58,4 +89,4 @@ class CRUDMovement:
).order_by(Movement.timestamp).all()
movement = CRUDMovement()
movement = CRUDMovement()