Skip to content

Commit 2ca8a6b

Browse files
committed
lint
1 parent f56fd66 commit 2ca8a6b

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

backend/app/database/face_clusters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def db_delete_all_clusters() -> int:
195195
return deleted_count
196196

197197

198-
def db_get_all_clusters_with_face_counts() -> List[
199-
Dict[str, Union[str, Optional[str], int]]
200-
]:
198+
def db_get_all_clusters_with_face_counts() -> (
199+
List[Dict[str, Union[str, Optional[str], int]]]
200+
):
201201
"""
202202
Retrieve all clusters with their face counts and stored face images.
203203

backend/app/database/faces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ def db_get_faces_unassigned_clusters() -> List[Dict[str, Union[FaceId, FaceEmbed
234234
return faces
235235

236236

237-
def db_get_all_faces_with_cluster_names() -> List[
238-
Dict[str, Union[FaceId, FaceEmbedding, Optional[str]]]
239-
]:
237+
def db_get_all_faces_with_cluster_names() -> (
238+
List[Dict[str, Union[FaceId, FaceEmbedding, Optional[str]]]]
239+
):
240240
"""
241241
Get all faces with their corresponding cluster names.
242242
@@ -271,7 +271,7 @@ def db_get_all_faces_with_cluster_names() -> List[
271271

272272

273273
def db_update_face_cluster_ids_batch(
274-
face_cluster_mapping: List[Dict[str, Union[FaceId, ClusterId]]]
274+
face_cluster_mapping: List[Dict[str, Union[FaceId, ClusterId]]],
275275
) -> None:
276276
"""
277277
Update cluster IDs for multiple faces in batch.

backend/app/database/folders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ def db_get_folder_ids_by_paths(
382382
conn.close()
383383

384384

385-
def db_get_all_folder_details() -> List[
386-
Tuple[str, str, Optional[str], int, bool, Optional[bool]]
387-
]:
385+
def db_get_all_folder_details() -> (
386+
List[Tuple[str, str, Optional[str], int, bool, Optional[bool]]]
387+
):
388388
"""
389389
Get all folder details including folder_id, folder_path, parent_folder_id,
390390
last_modified_time, AI_Tagging, and taggingCompleted.

backend/app/database/images.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ def db_toggle_image_favourite_status(image_id: str) -> bool:
391391
return False
392392
cursor.execute("PRAGMA table_info(images)")
393393
columns = [column[1] for column in cursor.fetchall()]
394-
if 'isFavourite' not in columns:
394+
if "isFavourite" not in columns:
395395
print("isFavourite column doesn't exist, adding it now...")
396-
cursor.execute("ALTER TABLE images ADD COLUMN isFavourite BOOLEAN DEFAULT 0")
396+
cursor.execute(
397+
"ALTER TABLE images ADD COLUMN isFavourite BOOLEAN DEFAULT 0"
398+
)
397399
conn.commit()
398400
cursor.execute(
399401
"""
@@ -412,4 +414,4 @@ def db_toggle_image_favourite_status(image_id: str) -> bool:
412414
conn.rollback()
413415
return False
414416
finally:
415-
conn.close()
417+
conn.close()

backend/app/routes/albums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
router = APIRouter()
3131

32+
3233
# GET /albums/ - Get all albums
3334
@router.get("/", response_model=GetAlbumsResponse)
3435
def get_albums(show_hidden: bool = Query(False)):

backend/app/routes/images.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from app.utils.images import image_util_parse_metadata
66
from pydantic import BaseModel
77
from app.database.images import db_toggle_image_favourite_status
8+
89
router = APIRouter()
910

1011

@@ -52,15 +53,15 @@ def get_all_images():
5253

5354
# Convert to response format
5455
image_data = [
55-
ImageData(
56+
ImageData(
5657
id=image["id"],
5758
path=image["path"],
5859
folder_id=image["folder_id"],
5960
thumbnailPath=image["thumbnailPath"],
6061
metadata=image_util_parse_metadata(image["metadata"]),
61-
isTagged=image["isTagged"],
62-
isFavourite=image.get("isFavourite", False),
63-
tags=image["tags"],
62+
isTagged=image["isTagged"],
63+
isFavourite=image.get("isFavourite", False),
64+
tags=image["tags"],
6465
)
6566
for image in images
6667
]
@@ -84,23 +85,35 @@ def get_all_images():
8485

8586
# adding add to favourite and remove from favourite routes
8687

88+
8789
class ToggleFavouriteRequest(BaseModel):
8890
image_id: str
91+
92+
8993
@router.post("/toggle-favourite")
9094
def toggle_favourite(req: ToggleFavouriteRequest):
9195
image_id = req.image_id
9296
try:
9397
success = db_toggle_image_favourite_status(image_id)
9498
if not success:
95-
raise HTTPException(status_code=404, detail="Image not found or failed to toggle")
99+
raise HTTPException(
100+
status_code=404, detail="Image not found or failed to toggle"
101+
)
96102
# Fetch updated status to return
97-
image = next((img for img in db_get_all_images() if img["id"] == image_id), None)
98-
return {"success": True, "image_id": image_id, "isFavourite": image.get("isFavourite", False)}
103+
image = next(
104+
(img for img in db_get_all_images() if img["id"] == image_id), None
105+
)
106+
return {
107+
"success": True,
108+
"image_id": image_id,
109+
"isFavourite": image.get("isFavourite", False),
110+
}
99111

100112
except Exception as e:
101113
print(f"Toggle favourite error: {e}")
102114
raise HTTPException(status_code=500, detail=f"Internal server error: {e}")
103115

116+
104117
class ImageInfoResponse(BaseModel):
105118
id: str
106119
path: str
@@ -111,6 +124,7 @@ class ImageInfoResponse(BaseModel):
111124
isFavourite: bool
112125
tags: Optional[List[str]] = None
113126

127+
114128
@router.get("/info/{image_id}", response_model=ImageInfoResponse)
115129
def get_image_info(image_id: str):
116130
# 1. Fetch all images
@@ -128,5 +142,5 @@ def get_image_info(image_id: str):
128142
metadata=image["metadata"],
129143
isTagged=image["isTagged"],
130144
isFavourite=image.get("isFavourite", False),
131-
tags=image.get("tags", [])
132-
)
145+
tags=image.get("tags", []),
146+
)

backend/app/utils/images.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def image_util_process_untagged_images() -> bool:
9999

100100

101101
def image_util_classify_and_face_detect_images(
102-
untagged_images: List[Dict[str, str]]
102+
untagged_images: List[Dict[str, str]],
103103
) -> None:
104104
"""Classify untagged images and detect faces if applicable."""
105105
object_classifier = ObjectClassifier()
@@ -262,7 +262,7 @@ def image_util_remove_obsolete_images(folder_id_list: List[int]) -> int:
262262

263263

264264
def image_util_create_folder_path_mapping(
265-
folder_ids: List[Tuple[int, str]]
265+
folder_ids: List[Tuple[int, str]],
266266
) -> Dict[str, int]:
267267
"""
268268
Create a dictionary mapping folder paths to their IDs.

0 commit comments

Comments
 (0)