Skip to content

Commit

Permalink
fix: feature count in task features count api (#904)
Browse files Browse the repository at this point in the history
* fix: feature count in task features count api

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* task_count passed in the upload multipolygon api

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
nrjadkry and pre-commit-ci[bot] authored Oct 12, 2023
1 parent a8be46c commit 40619b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,14 @@ async def upload_multi_project_boundary(
status_code=428, detail=f"Project with id {project_id} does not exist"
)

return {"message": "Project Boundary Uploaded", "project_id": f"{project_id}"}
# Get the number of tasks in a project
task_count = await tasks_crud.get_task_count_in_project(db, project_id)

return {
"message": "Project Boundary Uploaded",
"project_id": f"{project_id}",
"task_count": task_count,
}


@router.post("/task_split")
Expand Down
6 changes: 4 additions & 2 deletions src/backend/app/tasks/tasks_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ async def task_features_count(
# Assemble the final data list
data = []
for x in odk_details:
feature_count_query = f"""
feature_count_query = text(
f"""
select count(*) from features where project_id = {project_id} and task_id = {x['xmlFormId']}
"""
)

result = db.execute(feature_count_query)
feature_count = result.fetchone()
Expand All @@ -184,7 +186,7 @@ async def task_features_count(
"task_id": x["xmlFormId"],
"submission_count": x["submissions"],
"last_submission": x["lastSubmission"],
"feature_count": feature_count["count"],
"feature_count": feature_count[0],
}
)

Expand Down

0 comments on commit 40619b4

Please sign in to comment.