Skip to content

Commit

Permalink
feat(submission): add date range filter for geojson download (#2176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuj-Gupta4 authored Feb 11, 2025
1 parent 4a3e0e9 commit ec5fa80
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/backend/app/submissions/submission_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,25 @@ async def update_review_state(
@router.get("/download-submission-geojson")
async def download_submission_geojson(
project_user: Annotated[ProjectUserDict, Depends(project_contributors)],
submitted_date_range: Optional[str] = Query(
None,
title="Submitted Date Range",
description="Date range in format (e.g., 'YYYY-MM-DD,YYYY-MM-DD')",
),
):
"""Download submission geojson for a specific project."""
project = project_user.get("project")
data = await submission_crud.get_submission_by_project(project, {})
filters = {}

if submitted_date_range:
start_date, end_date = submitted_date_range.split(",")
filters = {
"$filter": (
f"__system/submissionDate ge {start_date}T00:00:00+00:00 "
f"and __system/submissionDate le {end_date}T23:59:59.999+00:00"
)
}
data = await submission_crud.get_submission_by_project(project, filters)
submission_json = data.get("value", [])

submission_geojson = await central_crud.convert_odk_submission_json_to_geojson(
Expand Down

0 comments on commit ec5fa80

Please sign in to comment.