Commit often...
This commit is contained in:
@@ -152,6 +152,7 @@ async def update_ppr_status(
|
||||
db,
|
||||
ppr_id=ppr_id,
|
||||
status=status_update.status,
|
||||
timestamp=status_update.timestamp,
|
||||
user=current_user.username,
|
||||
user_ip=client_ip
|
||||
)
|
||||
@@ -169,7 +170,7 @@ async def update_ppr_status(
|
||||
"id": ppr.id,
|
||||
"ac_reg": ppr.ac_reg,
|
||||
"status": ppr.status.value,
|
||||
"timestamp": ppr.landed_dt.isoformat() if ppr.landed_dt else None
|
||||
"timestamp": ppr.landed_dt.isoformat() if ppr.landed_dt else (ppr.departed_dt.isoformat() if ppr.departed_dt else None)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -71,6 +71,7 @@ class PPRUpdate(BaseModel):
|
||||
|
||||
class PPRStatusUpdate(BaseModel):
|
||||
status: PPRStatus
|
||||
timestamp: Optional[datetime] = None
|
||||
|
||||
|
||||
class PPRInDBBase(PPRBase):
|
||||
|
||||
Reference in New Issue
Block a user