mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(app): remove order_by in favor of starred_first for images records
This commit is contained in:
parent
f268fe126e
commit
c96ccae70b
@ -6,7 +6,7 @@ from invokeai.app.invocations.fields import MetadataField
|
||||
from invokeai.app.services.shared.pagination import OffsetPaginatedResults
|
||||
from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection
|
||||
|
||||
from .image_records_common import ImageCategory, ImageRecord, ImageRecordChanges, OrderByOptions, ResourceOrigin
|
||||
from .image_records_common import ImageCategory, ImageRecord, ImageRecordChanges, ResourceOrigin
|
||||
|
||||
|
||||
class ImageRecordStorageBase(ABC):
|
||||
@ -38,7 +38,7 @@ class ImageRecordStorageBase(ABC):
|
||||
self,
|
||||
offset: int = 0,
|
||||
limit: int = 10,
|
||||
order_by: OrderByOptions = OrderByOptions.CREATED_AT,
|
||||
starred_first: bool = True,
|
||||
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||
image_origin: Optional[ResourceOrigin] = None,
|
||||
categories: Optional[list[ImageCategory]] = None,
|
||||
|
@ -207,13 +207,3 @@ def deserialize_image_record(image_dict: dict) -> ImageRecord:
|
||||
starred=starred,
|
||||
has_workflow=has_workflow,
|
||||
)
|
||||
|
||||
|
||||
class OrderByOptions(str, Enum, metaclass=MetaEnum):
|
||||
"""Options for image ordering
|
||||
- `created_at`: order by created_at date
|
||||
- `starred`: order by starred and then created_at
|
||||
"""
|
||||
|
||||
CREATED_AT = "created_at"
|
||||
STARRED = "starred"
|
||||
|
@ -17,7 +17,6 @@ from .image_records_common import (
|
||||
ImageRecordDeleteException,
|
||||
ImageRecordNotFoundException,
|
||||
ImageRecordSaveException,
|
||||
OrderByOptions,
|
||||
ResourceOrigin,
|
||||
deserialize_image_record,
|
||||
)
|
||||
@ -146,7 +145,7 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
||||
self,
|
||||
offset: int = 0,
|
||||
limit: int = 10,
|
||||
order_by: OrderByOptions = OrderByOptions.CREATED_AT,
|
||||
starred_first: bool = True,
|
||||
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||
image_origin: Optional[ResourceOrigin] = None,
|
||||
categories: Optional[list[ImageCategory]] = None,
|
||||
@ -212,9 +211,9 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
||||
"""
|
||||
query_params.append(board_id)
|
||||
|
||||
if order_by == OrderByOptions.STARRED:
|
||||
if starred_first:
|
||||
query_pagination = f"""--sql
|
||||
ORDER BY images.starred {order_dir}, images.created_at {order_dir} LIMIT ? OFFSET ?
|
||||
ORDER BY images.starred DESC, images.created_at {order_dir} LIMIT ? OFFSET ?
|
||||
"""
|
||||
else:
|
||||
query_pagination = f"""--sql
|
||||
|
@ -8,7 +8,6 @@ from invokeai.app.services.image_records.image_records_common import (
|
||||
ImageCategory,
|
||||
ImageRecord,
|
||||
ImageRecordChanges,
|
||||
OrderByOptions,
|
||||
ResourceOrigin,
|
||||
)
|
||||
from invokeai.app.services.images.images_common import ImageDTO
|
||||
@ -118,7 +117,7 @@ class ImageServiceABC(ABC):
|
||||
self,
|
||||
offset: int = 0,
|
||||
limit: int = 10,
|
||||
order_by: OrderByOptions = OrderByOptions.CREATED_AT,
|
||||
starred_first: bool = True,
|
||||
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||
image_origin: Optional[ResourceOrigin] = None,
|
||||
categories: Optional[list[ImageCategory]] = None,
|
||||
|
@ -21,7 +21,6 @@ from ..image_records.image_records_common import (
|
||||
ImageRecordSaveException,
|
||||
InvalidImageCategoryException,
|
||||
InvalidOriginException,
|
||||
OrderByOptions,
|
||||
ResourceOrigin,
|
||||
)
|
||||
from .images_base import ImageServiceABC
|
||||
@ -209,7 +208,7 @@ class ImageService(ImageServiceABC):
|
||||
self,
|
||||
offset: int = 0,
|
||||
limit: int = 10,
|
||||
order_by: OrderByOptions = OrderByOptions.CREATED_AT,
|
||||
starred_first: bool = True,
|
||||
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||
image_origin: Optional[ResourceOrigin] = None,
|
||||
categories: Optional[list[ImageCategory]] = None,
|
||||
@ -220,7 +219,7 @@ class ImageService(ImageServiceABC):
|
||||
results = self.__invoker.services.image_records.get_many(
|
||||
offset,
|
||||
limit,
|
||||
order_by,
|
||||
starred_first,
|
||||
order_dir,
|
||||
image_origin,
|
||||
categories,
|
||||
|
Loading…
Reference in New Issue
Block a user