Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve route ambiguity for /tasks/activity endpoint #1924

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/backend/app/tasks/task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/ProjectSubmissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
);
}, []);

Expand Down
Loading