Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix s3 upload and db insertion for submission photos #1856

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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