diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index 37ff05a821..a79b162a57 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -2842,3 +2842,13 @@ def is_valid_coordinate(coord): if not is_valid_coordinate(first_coordinate): log.error(error_message) raise HTTPException(status_code=400, detail=error_message) + + +def get_tasks_count(db: Session, project_id: int): + db_task = ( + db.query(db_models.DbProject) + .filter(db_models.DbProject.id == project_id) + .first() + ) + task_count = len(db_task.tasks) + return task_count diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index 4d5063f5c4..5de5ecc31b 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -163,6 +163,7 @@ async def read_project_summaries( async def read_project(project_id: int, db: Session = Depends(database.get_db)): project = project_crud.get_project_by_id(db, project_id) if project: + project.project_uuid = uuid.uuid4() return project else: raise HTTPException(status_code=404, detail="Project not found") @@ -222,8 +223,8 @@ async def create_project( project = project_crud.create_project_with_project_info( db, project_info, odkproject["id"] ) - if project: + project.project_uuid = uuid.uuid4() return project else: raise HTTPException(status_code=404, detail="Project not found") @@ -800,8 +801,10 @@ async def generate_log( last_50_logs = filtered_logs[-50:] logs = "\n".join(last_50_logs) + task_count = project_crud.get_tasks_count(db, project_id) return { "status": task_status.name, + "total_tasks": task_count, "message": task_message, "progress": extract_completion_count, "logs": logs, diff --git a/src/backend/app/projects/project_schemas.py b/src/backend/app/projects/project_schemas.py index 46d6e2a57d..67a7abcf50 100644 --- a/src/backend/app/projects/project_schemas.py +++ b/src/backend/app/projects/project_schemas.py @@ -16,6 +16,7 @@ # along with FMTM. If not, see . # +import uuid from typing import List, Optional, Union from geojson_pydantic import Feature as GeojsonFeature @@ -136,4 +137,5 @@ class ProjectBase(BaseModel): class ProjectOut(ProjectBase): + project_uuid: uuid.UUID pass