feat(db,api): list images board_id="none" gets images without a board

This commit is contained in:
psychedelicious
2023-07-09 19:34:49 +10:00
parent 8501ca0843
commit cad358dc9a
2 changed files with 10 additions and 6 deletions

View File

@@ -220,7 +220,7 @@ async def list_images_with_metadata(
default=None, description="Whether to list intermediate images"
),
board_id: Optional[str] = Query(
default=None, description="The board id to filter by"
default=None, description="The board id to filter by, provide 'none' for images without a board"
),
offset: int = Query(default=0, description="The page offset"),
limit: int = Query(default=10, description="The number of images per page"),

View File

@@ -329,11 +329,15 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
query_params.append(is_intermediate)
if board_id is not None:
query_conditions += """--sql
AND board_images.board_id = ?
"""
query_params.append(board_id)
if board_id == "none":
query_conditions += """--sql
AND board_images.board_id IS NULL
"""
else:
query_conditions += """--sql
AND board_images.board_id = ?
"""
query_params.append(board_id)
query_pagination = """--sql
ORDER BY images.created_at DESC LIMIT ? OFFSET ?