From 4cf25a92299c92ad16d54c39ec41a97fe2147918 Mon Sep 17 00:00:00 2001 From: Sujan Adhikari <109404840+Sujanadh@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:51:07 +0545 Subject: [PATCH] fix(backend): resolve route ambiguity for /tasks/activity endpoint (#1924) * fix: resolve route ambiguity for /tasks/activity endpoint * fix: re-ordering of task endpoint --- src/backend/app/tasks/task_routes.py | 42 +++++++++---------- src/frontend/src/views/ProjectSubmissions.tsx | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/backend/app/tasks/task_routes.py b/src/backend/app/tasks/task_routes.py index e2dd110b63..3529b838e0 100644 --- a/src/backend/app/tasks/task_routes.py +++ b/src/backend/app/tasks/task_routes.py @@ -55,6 +55,27 @@ async def get_tasks_near_me( return "Coming..." +@router.get("/activity", response_model=list[task_schemas.TaskEventCount]) +async def task_activity( + project_id: int, + db: Annotated[Connection, Depends(db_conn)], + project_user: Annotated[ProjectUserDict, Depends(mapper)], + days: int = 10, +): + """Get the number of mapped or validated tasks on each day. + + Return format: + [ + { + date: DD/MM/YYYY, + validated: int, + mapped: int, + } + ] + """ + return await task_crud.get_project_task_activity(db, project_id, days) + + @router.get("/{task_id}", response_model=task_schemas.TaskOut) async def get_specific_task( task_id: int, @@ -84,27 +105,6 @@ async def add_new_task_event( return await DbTaskEvent.create(db, new_event) -@router.get("/activity", response_model=list[task_schemas.TaskEventCount]) -async def task_activity( - project_id: int, - db: Annotated[Connection, Depends(db_conn)], - project_user: Annotated[ProjectUserDict, Depends(mapper)], - days: int = 10, -): - """Get the number of mapped or validated tasks on each day. - - Return format: - [ - { - date: DD/MM/YYYY, - validated: int, - mapped: int, - } - ] - """ - return await task_crud.get_project_task_activity(db, project_id, days) - - @router.get("/{task_id}/history", response_model=list[task_schemas.TaskEventOut]) async def get_task_event_history( task_id: int, diff --git a/src/frontend/src/views/ProjectSubmissions.tsx b/src/frontend/src/views/ProjectSubmissions.tsx index 7782e183df..172bb94890 100644 --- a/src/frontend/src/views/ProjectSubmissions.tsx +++ b/src/frontend/src/views/ProjectSubmissions.tsx @@ -53,7 +53,7 @@ const ProjectSubmissions = () => { useEffect(() => { dispatch( - MappedVsValidatedTaskService(`${import.meta.env.VITE_API_URL}/tasks/activity?project_id=${projectId}&days=30`), + MappedVsValidatedTaskService(`${import.meta.env.VITE_API_URL}/tasks/activity/?project_id=${projectId}&days=30`), ); }, []);