From 97799505fbbc14add8f240ca16035686c884052b Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Tue, 29 Aug 2023 15:28:04 +0545 Subject: [PATCH] updated task wise submission api for project info --- src/backend/app/central/central_crud.py | 1 - src/backend/app/tasks/tasks_routes.py | 19 ++++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/backend/app/central/central_crud.py b/src/backend/app/central/central_crud.py index 183c418df6..46ff85d83d 100644 --- a/src/backend/app/central/central_crud.py +++ b/src/backend/app/central/central_crud.py @@ -279,7 +279,6 @@ def delete_odk_xform( return result -# def list_odk_xforms(project_id: int, odk_central: project_schemas.ODKCentral = None): def list_odk_xforms( project_id: int, odk_central: project_schemas.ODKCentral = None, diff --git a/src/backend/app/tasks/tasks_routes.py b/src/backend/app/tasks/tasks_routes.py index b0df3fdf0c..ff58e1b43b 100644 --- a/src/backend/app/tasks/tasks_routes.py +++ b/src/backend/app/tasks/tasks_routes.py @@ -172,21 +172,18 @@ async def task_features_count( # Assemble the final data list data = [] for x in odk_details: - feature_count_query = text( - f""" + feature_count_query = 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() - data.append( - { - "task_id": x["xmlFormId"], - "submission_count": x["submissions"], - "last_submission": x["lastSubmission"], - "feature_count": feature_count[0], - } - ) + data.append({ + 'task_id': x['xmlFormId'], + 'submission_count': x['submissions'], + 'last_submission': x['lastSubmission'], + 'feature_count': feature_count['count'] + }) return data