Skip to content

Commit

Permalink
fix(backend): s3 upload and db insertion for submission photos (#1856)
Browse files Browse the repository at this point in the history
* fix: s3 upload and db insertion for submission photos

* fix: split-by-square, changed payload dimension to dimension_meters
  • Loading branch information
Sujanadh authored Nov 6, 2024
1 parent db0674e commit 11d5430
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ class DbSubmissionPhoto(BaseModel):
TODO SQL this will be replace by ODK Central direct S3 upload.
"""

id: int
id: Optional[int] = None
project_id: Optional[int] = None
task_id: Optional[int] = None # Note this is not a DbTask, but an ODK task_id
submission_id: Optional[str] = None
Expand Down
3 changes: 2 additions & 1 deletion src/backend/app/submissions/submission_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ async def upload_attachment_to_s3(

# Perform batch insert if there are new records to insert
async with db.cursor() as cur:
await cur.execute(
await cur.executemany( # executes multiple inserts (batch insert)
"""
INSERT INTO submission_photos (
project_id,
Expand All @@ -358,6 +358,7 @@ async def upload_attachment_to_s3(
""",
batch_insert_data,
)
db.commit()
return True

except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions src/backend/app/submissions/submission_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ async def submission_table(
project.id,
instance_ids,
background_task_id,
db,
)

if task_id:
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const GetDividedTaskFromGeojson = (url: string, projectData: Record<string, any>
try {
const dividedTaskFormData = new FormData();
dividedTaskFormData.append('project_geojson', projectData.geojson);
dividedTaskFormData.append('dimension', projectData.dimension);
dividedTaskFormData.append('dimension_meters', projectData.dimension);
const getGetDividedTaskFromGeojsonResponse = await axios.post(url, dividedTaskFormData);
const resp: OrganisationListModel = getGetDividedTaskFromGeojsonResponse.data;
dispatch(CreateProjectActions.SetIsTasksGenerated({ key: 'divide_on_square', value: true }));
Expand Down

0 comments on commit 11d5430

Please sign in to comment.