refactor: update milestone/task status enums to new state machine values
Milestone: open/freeze/undergoing/completed/closed (was open/pending/deferred/progressing/closed) Task: open/pending/undergoing/completed/closed (was open/pending/progressing/closed) - Add MilestoneStatusEnum to schemas with typed validation - Add started_at field to Milestone model - Update all router/CLI references from progressing->undergoing - Add completed status handling in task transition logic
This commit is contained in:
@@ -167,9 +167,9 @@ def update_task(task_id: int, task_update: schemas.TaskUpdate, db: Session = Dep
|
||||
update_data = task_update.model_dump(exclude_unset=True)
|
||||
if "status" in update_data:
|
||||
new_status = update_data["status"]
|
||||
if new_status == "progressing" and not task.started_on:
|
||||
if new_status == "undergoing" and not task.started_on:
|
||||
task.started_on = datetime.utcnow()
|
||||
if new_status == "closed" and not task.finished_on:
|
||||
if new_status in ("closed", "completed") and not task.finished_on:
|
||||
task.finished_on = datetime.utcnow()
|
||||
|
||||
for field, value in update_data.items():
|
||||
@@ -202,9 +202,9 @@ def transition_task(task_id: int, new_status: str, bg: BackgroundTasks, db: Sess
|
||||
if not task:
|
||||
raise HTTPException(status_code=404, detail="Task not found")
|
||||
old_status = task.status.value if hasattr(task.status, 'value') else task.status
|
||||
if new_status == "progressing" and not task.started_on:
|
||||
if new_status == "undergoing" and not task.started_on:
|
||||
task.started_on = datetime.utcnow()
|
||||
if new_status == "closed" and not task.finished_on:
|
||||
if new_status in ("closed", "completed") and not task.finished_on:
|
||||
task.finished_on = datetime.utcnow()
|
||||
task.status = new_status
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user