Skip to content

Commit

Permalink
feat(backend): add methods for deleting DbBasemap & DbBackgroundTask
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 28, 2024
1 parent 3694396 commit 0f6452d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,23 @@ async def update(

return updated_task

@classmethod
async def delete(cls, db: Connection, background_task_id: UUID) -> bool:
"""Delete a background task entry."""
sql = """
DELETE from background_tasks
WHERE id = %(background_task_id)s
RETURNING id;
"""

async with db.cursor() as cur:
await cur.execute(sql, {"background_task_id": background_task_id})
success = await cur.fetchone()

if success:
return True
return False


class DbBasemap(BaseModel):
"""Table tiles_path.
Expand Down Expand Up @@ -1636,7 +1653,7 @@ async def create(
async def update(
cls,
db: Connection,
basemap_id: int,
basemap_id: UUID,
basemap_update: "BasemapUpdate",
) -> Self:
"""Update values for a basemap."""
Expand All @@ -1662,6 +1679,23 @@ async def update(

return updated_basemap

@classmethod
async def delete(cls, db: Connection, basemap_id: UUID) -> bool:
"""Delete a basemap."""
sql = """
DELETE from basemaps
WHERE id = %(basemap_id)s
RETURNING id;
"""

async with db.cursor() as cur:
await cur.execute(sql, {"basemap_id": basemap_id})
success = await cur.fetchone()

if success:
return True
return False


class DbSubmissionPhoto(BaseModel):
"""Table submission_photo.
Expand Down

0 comments on commit 0f6452d

Please sign in to comment.