chore: ruff

This commit is contained in:
psychedelicious
2025-06-25 01:20:04 +10:00
parent 6e3e316416
commit b204fb6a91
4 changed files with 8 additions and 3 deletions

View File

@@ -565,7 +565,9 @@ async def get_bulk_download_item(
raise HTTPException(status_code=404)
@images_router.get("/collections/counts", operation_id="get_image_collection_counts", response_model=ImageCollectionCounts)
@images_router.get(
"/collections/counts", operation_id="get_image_collection_counts", response_model=ImageCollectionCounts
)
async def get_image_collection_counts(
image_origin: Optional[ResourceOrigin] = Query(default=None, description="The origin of images to count."),
categories: Optional[list[ImageCategory]] = Query(default=None, description="The categories of image to include."),

View File

@@ -208,6 +208,7 @@ def deserialize_image_record(image_dict: dict) -> ImageRecord:
has_workflow=has_workflow,
)
class ImageCollectionCounts(BaseModel):
starred_count: int = Field(description="The number of starred images in the collection.")
unstarred_count: int = Field(description="The number of unstarred images in the collection.")

View File

@@ -626,9 +626,12 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
query_params.append(f"%{search_term.lower()}%")
# Order by starred first, then by created_at
query += query_conditions + f"""--sql
query += (
query_conditions
+ f"""--sql
ORDER BY images.starred DESC, images.created_at {order_dir.value}
"""
)
cursor.execute(query, query_params)
result = cast(list[sqlite3.Row], cursor.fetchall())

View File

@@ -1,4 +1,3 @@
from time import time
from typing import Literal, Optional
from PIL.Image import Image as PILImageType