mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add optional search term to search image metadata
This commit is contained in:
parent
e3e8d689d7
commit
89c5662848
@ -316,6 +316,7 @@ async def list_image_dtos(
|
|||||||
),
|
),
|
||||||
offset: int = Query(default=0, description="The page offset"),
|
offset: int = Query(default=0, description="The page offset"),
|
||||||
limit: int = Query(default=10, description="The number of images per page"),
|
limit: int = Query(default=10, description="The number of images per page"),
|
||||||
|
search_term: Optional[str] = Query(default=None, description="The term to search for"),
|
||||||
) -> OffsetPaginatedResults[ImageDTO]:
|
) -> OffsetPaginatedResults[ImageDTO]:
|
||||||
"""Gets a list of image DTOs"""
|
"""Gets a list of image DTOs"""
|
||||||
|
|
||||||
@ -326,6 +327,7 @@ async def list_image_dtos(
|
|||||||
categories,
|
categories,
|
||||||
is_intermediate,
|
is_intermediate,
|
||||||
board_id,
|
board_id,
|
||||||
|
search_term
|
||||||
)
|
)
|
||||||
|
|
||||||
return image_dtos
|
return image_dtos
|
||||||
|
@ -41,6 +41,7 @@ class ImageRecordStorageBase(ABC):
|
|||||||
categories: Optional[list[ImageCategory]] = None,
|
categories: Optional[list[ImageCategory]] = None,
|
||||||
is_intermediate: Optional[bool] = None,
|
is_intermediate: Optional[bool] = None,
|
||||||
board_id: Optional[str] = None,
|
board_id: Optional[str] = None,
|
||||||
|
search_term: Optional[str] = None,
|
||||||
) -> OffsetPaginatedResults[ImageRecord]:
|
) -> OffsetPaginatedResults[ImageRecord]:
|
||||||
"""Gets a page of image records."""
|
"""Gets a page of image records."""
|
||||||
pass
|
pass
|
||||||
|
@ -148,6 +148,7 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
categories: Optional[list[ImageCategory]] = None,
|
categories: Optional[list[ImageCategory]] = None,
|
||||||
is_intermediate: Optional[bool] = None,
|
is_intermediate: Optional[bool] = None,
|
||||||
board_id: Optional[str] = None,
|
board_id: Optional[str] = None,
|
||||||
|
search_term: Optional[str] = None,
|
||||||
) -> OffsetPaginatedResults[ImageRecord]:
|
) -> OffsetPaginatedResults[ImageRecord]:
|
||||||
try:
|
try:
|
||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
@ -208,6 +209,13 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
"""
|
"""
|
||||||
query_params.append(board_id)
|
query_params.append(board_id)
|
||||||
|
|
||||||
|
# Search term condition
|
||||||
|
if search_term:
|
||||||
|
query_conditions += """--sql
|
||||||
|
AND json_extract(images.metadata, '$') LIKE ?
|
||||||
|
"""
|
||||||
|
query_params.append(f'%{search_term}%')
|
||||||
|
|
||||||
query_pagination = """--sql
|
query_pagination = """--sql
|
||||||
ORDER BY images.starred DESC, images.created_at DESC LIMIT ? OFFSET ?
|
ORDER BY images.starred DESC, images.created_at DESC LIMIT ? OFFSET ?
|
||||||
"""
|
"""
|
||||||
|
@ -120,6 +120,7 @@ class ImageServiceABC(ABC):
|
|||||||
categories: Optional[list[ImageCategory]] = None,
|
categories: Optional[list[ImageCategory]] = None,
|
||||||
is_intermediate: Optional[bool] = None,
|
is_intermediate: Optional[bool] = None,
|
||||||
board_id: Optional[str] = None,
|
board_id: Optional[str] = None,
|
||||||
|
search_term: Optional[str] = None
|
||||||
) -> OffsetPaginatedResults[ImageDTO]:
|
) -> OffsetPaginatedResults[ImageDTO]:
|
||||||
"""Gets a paginated list of image DTOs."""
|
"""Gets a paginated list of image DTOs."""
|
||||||
pass
|
pass
|
||||||
|
@ -206,6 +206,7 @@ class ImageService(ImageServiceABC):
|
|||||||
categories: Optional[list[ImageCategory]] = None,
|
categories: Optional[list[ImageCategory]] = None,
|
||||||
is_intermediate: Optional[bool] = None,
|
is_intermediate: Optional[bool] = None,
|
||||||
board_id: Optional[str] = None,
|
board_id: Optional[str] = None,
|
||||||
|
search_term: Optional[str] = None,
|
||||||
) -> OffsetPaginatedResults[ImageDTO]:
|
) -> OffsetPaginatedResults[ImageDTO]:
|
||||||
try:
|
try:
|
||||||
results = self.__invoker.services.image_records.get_many(
|
results = self.__invoker.services.image_records.get_many(
|
||||||
@ -215,6 +216,7 @@ class ImageService(ImageServiceABC):
|
|||||||
categories,
|
categories,
|
||||||
is_intermediate,
|
is_intermediate,
|
||||||
board_id,
|
board_id,
|
||||||
|
search_term
|
||||||
)
|
)
|
||||||
|
|
||||||
image_dtos = [
|
image_dtos = [
|
||||||
|
Loading…
Reference in New Issue
Block a user