Skip to content

Commit

Permalink
refractor: state of the tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Aug 9, 2024
1 parent cd5cc57 commit 3019bd1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/backend/app/tasks/task_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ async def get_tasks_by_user(user_id: str, db: Database):
task_details.task_area,
task_details.created_at,
CASE
WHEN task_details.state = 'REQUEST_FOR_MAPPING' THEN 'ongoing'
WHEN task_details.state = 'UNLOCKED_TO_MAP' THEN 'ready to map'
WHEN task_details.state = 'LOCKED_FOR_MAPPING' THEN 'locked for mapping'
WHEN task_details.state = 'UNLOCKED_TO_VALIDATE' THEN 'mapped'
WHEN task_details.state = 'LOCKED_FOR_VALIDATION' THEN 'mapped'
WHEN task_details.state = 'REQUEST_FOR_MAPPING' THEN 'request logs'
WHEN task_details.state = 'LOCKED_FOR_MAPPING' THEN 'ongoing'
WHEN task_details.state = 'UNLOCKED_DONE' THEN 'completed'
WHEN task_details.state = 'UNFLYABLE_TASK' THEN 'unflyable task'
ELSE 'unknown' -- Default case if the state does not match any expected 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 @@ -69,8 +69,8 @@ async def get_task_stats(
raise HTTPException(status_code=404, detail="User profile not found")
raw_sql = """
SELECT
COUNT(CASE WHEN te.state = 'LOCKED_FOR_MAPPING' THEN 1 END) AS ongoing_tasks,
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 = 'UNLOCKED_DONE' THEN 1 END) AS completed_tasks,
COUNT(CASE WHEN te.state = 'UNFLYABLE_TASK' THEN 1 END) AS unflyable_tasks
FROM tasks t
Expand Down

0 comments on commit 3019bd1

Please sign in to comment.