Skip to content

Commit

Permalink
fix: optimize project status calculation logic & update ongoing statu…
Browse files Browse the repository at this point in the history
…s count.
  • Loading branch information
Pradip-p committed Oct 9, 2024
1 parent f57bdc9 commit 8a7ce11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ def calculate_status(cls, values):
completed_task_count = values.completed_task_count
total_task_count = values.total_task_count

if ongoing_task_count == 0:
if completed_task_count == 0 and ongoing_task_count == 0:
values.status = "not-started"
elif ongoing_task_count > 0 and ongoing_task_count != completed_task_count:
values.status = "ongoing"
elif ongoing_task_count == total_task_count:
elif completed_task_count == total_task_count:
values.status = "completed"
else:
values.status = "ongoing"

return values

Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/tasks/task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def get_task_stats(
raw_sql = """
SELECT
COUNT(CASE WHEN te.state = 'REQUEST_FOR_MAPPING' THEN 1 END) AS request_logs,
COUNT(CASE WHEN te.state = 'LOCKED_FOR_MAPPING' THEN 1 END) AS ongoing_tasks,
COUNT(CASE WHEN te.state IN ('LOCKED_FOR_MAPPING', 'REQUEST_FOR_MAPPING', 'IMAGE_UPLOADED', 'UNFLYABLE_TASK') THEN 1 END) AS ongoing_tasks,
COUNT(CASE WHEN te.state = 'IMAGE_PROCESSED' THEN 1 END) AS completed_tasks,
COUNT(CASE WHEN te.state = 'UNFLYABLE_TASK' THEN 1 END) AS unflyable_tasks
FROM (
Expand Down

0 comments on commit 8a7ce11

Please sign in to comment.