Skip to content

Commit

Permalink
fix: refine the state of task processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Oct 8, 2024
1 parent d633c45 commit 1f7bb9e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
14 changes: 2 additions & 12 deletions src/backend/app/projects/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,6 @@ async def process_images_from_s3(self, bucket_name, name=None, options=[]):

images_list = self.list_images(temp_dir)

await task_logic.update_task_state(
self.db,
self.project.id,
self.task_id,
self.user_id,
"Task images processing started.",
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSED,
timestamp(),
)
# Start a new processing task
task = self.process_new_task(images_list, name=name, options=options)
# Monitor task progress
Expand All @@ -168,12 +158,12 @@ async def process_images_from_s3(self, bucket_name, name=None, options=[]):
# now update the task as completed in Db.
await task_logic.update_task_state(
self.db,
self.project_id,
self.project.id,
self.task_id,
self.user_id,
"Task completed.",
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSED,
State.UNLOCKED_DONE,
timestamp(),
)
return task
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ async def one(db: Connection, project_id: uuid.UUID):
CASE
WHEN te.state = 'REQUEST_FOR_MAPPING' THEN 'request logs'
WHEN te.state = 'LOCKED_FOR_MAPPING' THEN 'ongoing'
WHEN te.state = 'UNLOCKED_DONE' THEN 'completed'
WHEN te.state = 'IMAGE_PROCESSED' THEN 'completed'
WHEN te.state = 'UNFLYABLE_TASK' THEN 'unflyable task'
ELSE 'UNLOCKED_TO_MAP'
END AS calculated_state
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 @@ -97,7 +97,7 @@ async def get_task_stats(
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 = 'UNLOCKED_DONE' THEN 1 END) AS completed_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 (
SELECT DISTINCT ON (te.task_id)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/tasks/task_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async def get_tasks_by_user(
CASE
WHEN task_events.state = 'REQUEST_FOR_MAPPING' THEN 'request logs'
WHEN task_events.state = 'LOCKED_FOR_MAPPING' THEN 'ongoing'
WHEN task_events.state = 'UNLOCKED_DONE' THEN 'completed'
WHEN task_events.state = 'IMAGE_PROCESSED' THEN 'completed'
WHEN task_events.state = 'UNFLYABLE_TASK' THEN 'unflyable task'
ELSE 'UNLOCKED_TO_MAP'
END AS state
Expand Down

0 comments on commit 1f7bb9e

Please sign in to comment.