Commit often...

This commit is contained in:
James Pattinson
2025-10-23 16:43:01 +00:00
parent 981bb39888
commit b2f60322a1
5 changed files with 256 additions and 14 deletions

View File

@@ -110,6 +110,7 @@ class CRUDPPR:
db: Session,
ppr_id: int,
status: PPRStatus,
timestamp: Optional[datetime] = None,
user: str = "system",
user_ip: str = "127.0.0.1"
) -> Optional[PPRRecord]:
@@ -120,11 +121,12 @@ class CRUDPPR:
old_status = db_obj.status
db_obj.status = status
# Set timestamps based on status
# Set timestamps based on status - use provided timestamp or current time
current_time = timestamp if timestamp is not None else datetime.utcnow()
if status == PPRStatus.LANDED:
db_obj.landed_dt = datetime.utcnow()
db_obj.landed_dt = current_time
elif status == PPRStatus.DEPARTED:
db_obj.departed_dt = datetime.utcnow()
db_obj.departed_dt = current_time
db.add(db_obj)
db.commit()