Skip to content

Commit

Permalink
returne empty list for no submission
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadh committed Dec 26, 2023
1 parent 1290c59 commit fbb5de2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/backend/app/submission/submission_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,10 @@ async def get_submissions_by_date(db: Session, project_id: int, days: int, plann
s3_project_path = f"/{project.organisation_id}/{project_id}"
s3_submission_path = f"/{s3_project_path}/submission.zip"

if s3_submission_path is None:
return Response("Submissions not found, please upload it first")
file = get_obj_from_bucket(settings.S3_BUCKET_NAME, s3_submission_path)
try:
file = get_obj_from_bucket(settings.S3_BUCKET_NAME, s3_submission_path)
except ValueError as e:
return []

with zipfile.ZipFile(file, "r") as zip_ref:
with zip_ref.open("submissions.json") as file_in_zip:
Expand All @@ -860,7 +861,7 @@ async def get_submissions_by_date(db: Session, project_id: int, days: int, plann
submission_counts = Counter(sorted(dates))

response = [
{"date": key, "count": value, "planned": planned_task}
{"date": key, "count": value}
for key, value in submission_counts.items()
]
if planned_task:
Expand Down

0 comments on commit fbb5de2

Please sign in to comment.