Skip to content

Commit

Permalink
feat: added total task count in generate-log
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadh committed Nov 7, 2023
1 parent 8f8919b commit 4fc6acc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2812,3 +2812,9 @@ 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
5 changes: 4 additions & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ async def create_project(
project = project_crud.create_project_with_project_info(
db, project_info, odkproject["id"]
)

project_uuid = uuid.uuid4()
if project:
project.project_uuid = project_uuid
return project
else:
raise HTTPException(status_code=404, detail="Project not found")
Expand Down Expand Up @@ -725,8 +726,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,
Expand Down

0 comments on commit 4fc6acc

Please sign in to comment.