Skip to content

Commit 4b754ee

Browse files
committed
Format backend image helpers
1 parent ebd5ba8 commit 4b754ee

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

backend/app/database/images.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,22 @@ def db_toggle_image_favourite_status(image_id: str) -> bool:
457457
finally:
458458
conn.close()
459459

460+
460461
def db_get_image_by_id(image_id: str) -> Optional[dict]:
461462
"""
462463
Get a single image by ID with its favorite status.
463464
"""
464465
conn = _connect()
465466
cursor = conn.cursor()
466467
try:
467-
cursor.execute("""
468+
cursor.execute(
469+
"""
468470
SELECT id, path, folder_id, thumbnailPath, metadata, isTagged, isFavourite
469471
FROM images
470472
WHERE id = ?
471-
""", (image_id,))
473+
""",
474+
(image_id,),
475+
)
472476
row = cursor.fetchone()
473477
if not row:
474478
return None
@@ -488,6 +492,7 @@ def db_get_image_by_id(image_id: str) -> Optional[dict]:
488492
finally:
489493
conn.close()
490494

495+
491496
# ============================================================================
492497
# MEMORIES FEATURE - Location and Time-based Queries
493498
# ============================================================================

backend/app/routes/images.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def toggle_favourite(req: ToggleFavouriteRequest):
106106
success = db_toggle_image_favourite_status(image_id)
107107
if not success:
108108
raise HTTPException(
109-
status_code=status.HTTP_404_NOT_FOUND,
110-
detail="Image not found or failed to toggle"
109+
status_code=status.HTTP_404_NOT_FOUND,
110+
detail="Image not found or failed to toggle",
111111
)
112112
# Fetch updated status to return
113113
image = db_get_image_by_id(image_id)
114114
if not image:
115115
raise HTTPException(
116-
status_code=status.HTTP_404_NOT_FOUND,
117-
detail="Image not found after toggle"
116+
status_code=status.HTTP_404_NOT_FOUND,
117+
detail="Image not found after toggle",
118118
)
119119
return {
120120
"success": True,
@@ -126,10 +126,11 @@ def toggle_favourite(req: ToggleFavouriteRequest):
126126
except Exception as e:
127127
logger.error(f"error in /toggle-favourite route: {e}")
128128
raise HTTPException(
129-
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
130-
detail=f"Internal server error: {e}"
129+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
130+
detail=f"Internal server error: {e}",
131131
)
132132

133+
133134
class ImageInfoResponse(BaseModel):
134135
id: str
135136
path: str

0 commit comments

Comments
 (0)