Skip to content

Commit

Permalink
fix: resolved image processing issues, state management for color, an…
Browse files Browse the repository at this point in the history
…d dashboard listing
  • Loading branch information
Pradip-p committed Dec 12, 2024
1 parent af030d9 commit 822a86e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ async def odm_webhook(
current_state = await task_logic.get_task_state(db, dtm_project_id, dtm_task_id)
current_state_value = State[current_state.get("state")]
match current_state_value:
case State.IMAGE_UPLOADED:
case State.IMAGE_PROCESSING_STARTED:
log.info(
f"Task ID: {task_id}, Status: already IMAGE_UPLOADED - no update needed."
)
Expand All @@ -537,7 +537,7 @@ async def odm_webhook(
dtm_project_id,
dtm_task_id,
dtm_user_id,
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSING_STARTED,
"Task completed.",
)

Expand All @@ -553,7 +553,7 @@ async def odm_webhook(
dtm_project_id,
dtm_task_id,
dtm_user_id,
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSING_FAILED,
"Task completed.",
)

Expand All @@ -572,7 +572,7 @@ async def odm_webhook(
dtm_task_id,
dtm_user_id,
"Image processing failed.",
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSING_STARTED,
State.IMAGE_PROCESSING_FAILED,
timestamp(),
)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/tasks/task_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def get_task_stats(db: Connection, user_data: AuthUser):
raw_sql = """
SELECT
COUNT(CASE WHEN te.state = 'REQUEST_FOR_MAPPING' THEN 1 END) AS request_logs,
COUNT(CASE WHEN te.state IN ('LOCKED_FOR_MAPPING', 'IMAGE_UPLOADED', 'IMAGE_PROCESSING_FAILED') THEN 1 END) AS ongoing_tasks,
COUNT(CASE WHEN te.state IN ('LOCKED_FOR_MAPPING', 'IMAGE_UPLOADED', 'IMAGE_PROCESSING_STARTED','IMAGE_PROCESSING_FAILED') THEN 1 END) AS ongoing_tasks,
COUNT(CASE WHEN te.state = 'IMAGE_PROCESSING_FINISHED' THEN 1 END) AS completed_tasks,
COUNT(CASE WHEN te.state = 'UNFLYABLE_TASK' THEN 1 END) AS unflyable_tasks
Expand Down Expand Up @@ -642,7 +642,7 @@ async def handle_event(
task_id,
user_id,
f"Task image processing started by user {user_data.name}.",
State[state],
State.IMAGE_UPLOADED,
State.IMAGE_PROCESSING_STARTED,
detail.updated_at,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Legend = () => {
</div>
<div className="naxatw-flex naxatw-gap-2">
<div className="naxatw-h-5 naxatw-w-5 naxatw-bg-[#9C77B2] naxatw-opacity-60" />
<p className="naxatw-text-sm">Image Processing</p>
<p className="naxatw-text-sm">Image Processing Started</p>
</div>
<div className="naxatw-flex naxatw-gap-2">
<div className="naxatw-h-5 naxatw-w-5 naxatw-bg-[#D73F3F] naxatw-opacity-60" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ const MapSection = ({ projectData }: { projectData: Record<string, any> }) => {
return 'This task is not flyable';
case 'IMAGE_UPLOADED':
return `This task's Images has been uploaded ${properties.locked_user_name ? `by ${userDetails?.id === properties?.locked_user_id ? 'you' : properties?.locked_user_name}` : ''}`;
case 'IMAGE_PROCESSED':
case 'IMAGE_PROCESSING_STARTED':
return `This task is started ${properties.locked_user_name ? `by ${userDetails?.id === properties?.locked_user_id ? 'you' : properties?.locked_user_name}` : ''}`;
case 'IMAGE_PROCESSING_FINISHED':
return `This task is completed ${properties.locked_user_name ? `by ${userDetails?.id === properties?.locked_user_id ? 'you' : properties?.locked_user_name}` : ''}`;
case 'IMAGE_PROCESSING_FAILED':
return `This task's image processing is failed started ${properties.locked_user_name ? `by ${userDetails?.id === properties?.locked_user_id ? 'you' : properties?.locked_user_name}` : ''}`;
return `The image processing task started ${userDetails?.id === properties?.locked_user_id ? 'by you' : `by ${properties?.locked_user_name}`} has failed.`;
default:
return '';
}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const rowsPerPageOptions = [

export const taskStatusObj = {
request_logs: ['REQUEST_FOR_MAPPING'],
ongoing: ['LOCKED_FOR_MAPPING', 'IMAGE_UPLOADED', 'IMAGE_PROCESSING_FAILED'],
completed: ['IMAGE_PROCESSED'],
ongoing: ['LOCKED_FOR_MAPPING', 'IMAGE_UPLOADED', 'IMAGE_PROCESSING_STARTED', 'IMAGE_PROCESSING_FAILED'],
completed: ['IMAGE_PROCESSING_FINISHED'],
unflyable: ['UNFLYABLE_TASK'],
};
7 changes: 5 additions & 2 deletions src/frontend/src/constants/projectDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getLayerOptionsByStatus = (status: string) => {
'fill-opacity': 0.5,
},
},
IMAGE_PROCESSED: {
IMAGE_PROCESSING_FINISHED: {
type: 'fill',
paint: {
'fill-color': '#ACD2C4',
Expand Down Expand Up @@ -94,7 +94,10 @@ export const showPrimaryButton = (
case 'IMAGE_UPLOADED':
if (lockedUser === currentUser || author === currentUser) return true;
return false;
case 'IMAGE_PROCESSED':
case 'IMAGE_PROCESSING_STARTED':
if (lockedUser === currentUser || author === currentUser) return true;
return false;
case 'IMAGE_PROCESSING_FINISHED':
return true;
case 'IMAGE_PROCESSING_FAILED':
if (lockedUser === currentUser || author === currentUser) return true;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const getFrontOverlap = (agl: number, forwardSpacing: number) => {
// remove underscore and capitalize the word
export const formatString = (value: string) => {
if (!value) return '';
if (value === 'IMAGE_PROCESSED') return 'Completed';
if (value === 'IMAGE_PROCESSING_FINISHED') return 'Completed';
return value
.replace(/_/g, ' ')
.toLowerCase()
Expand Down

0 comments on commit 822a86e

Please sign in to comment.