From 97799505fbbc14add8f240ca16035686c884052b Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Tue, 29 Aug 2023 15:28:04 +0545 Subject: [PATCH 1/2] 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 From 682fde5f0cf7dd8c5e5c359aa05286296f052ed4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:17:31 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/backend/app/tasks/tasks_routes.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/backend/app/tasks/tasks_routes.py b/src/backend/app/tasks/tasks_routes.py index ff58e1b43b..92386da921 100644 --- a/src/backend/app/tasks/tasks_routes.py +++ b/src/backend/app/tasks/tasks_routes.py @@ -179,11 +179,13 @@ async def task_features_count( 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['count'] - }) + data.append( + { + "task_id": x["xmlFormId"], + "submission_count": x["submissions"], + "last_submission": x["lastSubmission"], + "feature_count": feature_count["count"], + } + ) return data