From 85efa9f907ca9c382b309165c2d39f7c9fa1a965 Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Tue, 6 Aug 2024 22:55:52 +0545 Subject: [PATCH] update dem_url into database --- src/backend/app/projects/project_crud.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index 751a606b..cd689897 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -16,6 +16,17 @@ from app.config import settings +async def update_project_dem_url(db: Database, project_id: uuid.UUID, dem_url: str): + """Update the DEM URL for a project.""" + query = """ + UPDATE projects + SET dem_url = :dem_url + WHERE id = :project_id + """ + await db.execute(query, {"dem_url": dem_url, "project_id": project_id}) + return True + + async def upload_dem_to_s3(project_id: uuid.UUID, dem_file: UploadFile) -> str: """Upload dem into S3. @@ -26,7 +37,7 @@ async def upload_dem_to_s3(project_id: uuid.UUID, dem_file: UploadFile) -> str: Returns: dem_url(str): The S3 URL for the dem file. """ - dem_path = f"/{project_id}/dem/dem.tif" + dem_path = f"/dem/{project_id}/dem.tif" file_bytes = await dem_file.read() file_obj = BytesIO(file_bytes)