Skip to content

Commit 8d043e5

Browse files
committed
style: apply black formatting to images.py files
1 parent c056096 commit 8d043e5

2 files changed

Lines changed: 24 additions & 29 deletions

File tree

backend/app/database/images.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def db_create_images_table() -> None:
6262
cursor = conn.cursor()
6363

6464
# Create new images table with merged fields including Memories feature columns
65-
cursor.execute(
66-
"""
65+
cursor.execute("""
6766
CREATE TABLE IF NOT EXISTS images (
6867
id TEXT PRIMARY KEY,
6968
path VARCHAR UNIQUE,
@@ -77,8 +76,7 @@ def db_create_images_table() -> None:
7776
captured_at DATETIME,
7877
FOREIGN KEY (folder_id) REFERENCES folders(folder_id) ON DELETE CASCADE
7978
)
80-
"""
81-
)
79+
""")
8280

8381
# Create indexes for Memories feature queries
8482
cursor.execute("CREATE INDEX IF NOT EXISTS ix_images_latitude ON images(latitude)")
@@ -93,17 +91,15 @@ def db_create_images_table() -> None:
9391
)
9492

9593
# Create new image_classes junction table
96-
cursor.execute(
97-
"""
94+
cursor.execute("""
9895
CREATE TABLE IF NOT EXISTS image_classes (
9996
image_id TEXT,
10097
class_id INTEGER,
10198
PRIMARY KEY (image_id, class_id),
10299
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
103100
FOREIGN KEY (class_id) REFERENCES mappings(class_id) ON DELETE CASCADE
104101
)
105-
"""
106-
)
102+
""")
107103

108104
conn.commit()
109105
conn.close()
@@ -265,15 +261,13 @@ def db_get_untagged_images() -> List[UntaggedImageRecord]:
265261
cursor = conn.cursor()
266262

267263
try:
268-
cursor.execute(
269-
"""
264+
cursor.execute("""
270265
SELECT i.id, i.path, i.folder_id, i.thumbnailPath, i.metadata
271266
FROM images i
272267
JOIN folders f ON i.folder_id = f.folder_id
273268
WHERE f.AI_Tagging = TRUE
274269
AND i.isTagged = FALSE
275-
"""
276-
)
270+
""")
277271

278272
results = cursor.fetchall()
279273

@@ -457,18 +451,22 @@ def db_toggle_image_favourite_status(image_id: str) -> bool:
457451
finally:
458452
conn.close()
459453

454+
460455
def db_get_image_by_id(image_id: str) -> Optional[dict]:
461456
"""
462457
Get a single image by ID with its favorite status.
463458
"""
464459
conn = _connect()
465460
cursor = conn.cursor()
466461
try:
467-
cursor.execute("""
462+
cursor.execute(
463+
"""
468464
SELECT id, path, folder_id, thumbnailPath, metadata, isTagged, isFavourite
469465
FROM images
470466
WHERE id = ?
471-
""", (image_id,))
467+
""",
468+
(image_id,),
469+
)
472470
row = cursor.fetchone()
473471
if not row:
474472
return None
@@ -488,6 +486,7 @@ def db_get_image_by_id(image_id: str) -> Optional[dict]:
488486
finally:
489487
conn.close()
490488

489+
491490
# ============================================================================
492491
# MEMORIES FEATURE - Location and Time-based Queries
493492
# ============================================================================
@@ -749,8 +748,7 @@ def db_get_images_with_location() -> List[dict]:
749748
cursor = conn.cursor()
750749

751750
try:
752-
cursor.execute(
753-
"""
751+
cursor.execute("""
754752
SELECT
755753
i.id,
756754
i.path,
@@ -770,8 +768,7 @@ def db_get_images_with_location() -> List[dict]:
770768
AND i.longitude IS NOT NULL
771769
GROUP BY i.id
772770
ORDER BY i.captured_at DESC
773-
"""
774-
)
771+
""")
775772

776773
results = cursor.fetchall()
777774

@@ -816,8 +813,7 @@ def db_get_all_images_for_memories() -> List[dict]:
816813
cursor = conn.cursor()
817814

818815
try:
819-
cursor.execute(
820-
"""
816+
cursor.execute("""
821817
SELECT
822818
i.id,
823819
i.path,
@@ -835,8 +831,7 @@ def db_get_all_images_for_memories() -> List[dict]:
835831
LEFT JOIN mappings m ON ic.class_id = m.class_id
836832
GROUP BY i.id
837833
ORDER BY i.captured_at DESC
838-
"""
839-
)
834+
""")
840835

841836
results = cursor.fetchall()
842837

backend/app/routes/images.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from app.database.images import db_toggle_image_favourite_status, db_get_image_by_id
88
from app.logging.setup_logging import get_logger
99

10-
1110
# Initialize logger
1211
logger = get_logger(__name__)
1312
router = APIRouter()
@@ -106,15 +105,15 @@ def toggle_favourite(req: ToggleFavouriteRequest):
106105
success = db_toggle_image_favourite_status(image_id)
107106
if not success:
108107
raise HTTPException(
109-
status_code=status.HTTP_404_NOT_FOUND,
110-
detail="Image not found or failed to toggle"
108+
status_code=status.HTTP_404_NOT_FOUND,
109+
detail="Image not found or failed to toggle",
111110
)
112111
# Fetch updated status to return
113112
image = db_get_image_by_id(image_id)
114113
if not image:
115114
raise HTTPException(
116-
status_code=status.HTTP_404_NOT_FOUND,
117-
detail="Image not found after toggle"
115+
status_code=status.HTTP_404_NOT_FOUND,
116+
detail="Image not found after toggle",
118117
)
119118
return {
120119
"success": True,
@@ -126,10 +125,11 @@ def toggle_favourite(req: ToggleFavouriteRequest):
126125
except Exception as e:
127126
logger.error(f"error in /toggle-favourite route: {e}")
128127
raise HTTPException(
129-
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
130-
detail=f"Internal server error: {e}"
128+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
129+
detail=f"Internal server error: {e}",
131130
)
132131

132+
133133
class ImageInfoResponse(BaseModel):
134134
id: str
135135
path: str

0 commit comments

Comments
 (0)