Skip to content

Commit

Permalink
refactor: changed sync to async gather_all_submission_csvs (#1258)
Browse files Browse the repository at this point in the history
Co-authored-by: sujanadh <sujanadh07@gmail.com>
  • Loading branch information
Sujanadh and sujanadh authored Feb 23, 2024
1 parent ff32c52 commit 3212ba4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/backend/app/submissions/submission_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,14 @@ def convert_to_osm(db: Session, project_id: int, task_id: int):
return FileResponse(final_zip_file_path)


def gather_all_submission_csvs(db, project_id):
async def gather_all_submission_csvs(db, project_id):
"""Gather all of the submission CSVs for a project.
Generate a single zip with all submissions.
"""
log.info(f"Downloading all CSV submissions for project {project_id}")

get_project_sync = async_to_sync(project_crud.get_project)
project_info = get_project_sync(db, project_id)
project_info = await project_crud.get_project(db, project_id)

odkid = project_info.odkid
project_name = project_info.project_name_prefix
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/submissions/submission_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def download_submission(
Union[list[dict], File]: JSON of submissions, or submission file.
"""
if not (task_id or export_json):
file = submission_crud.gather_all_submission_csvs(db, project_id)
file = await submission_crud.gather_all_submission_csvs(db, project_id)
return FileResponse(file)

return await submission_crud.download_submission(
Expand Down

0 comments on commit 3212ba4

Please sign in to comment.