mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(db): tidy image_record_storage.py
This commit is contained in:
@ -287,11 +287,6 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
|
|
||||||
# Manually build two queries - one for the count, one for the records
|
# Manually build two queries - one for the count, one for the records
|
||||||
|
|
||||||
# count_query = """--sql
|
|
||||||
# SELECT COUNT(*) FROM images WHERE 1=1
|
|
||||||
# """
|
|
||||||
|
|
||||||
count_query = """--sql
|
count_query = """--sql
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM images
|
FROM images
|
||||||
@ -306,10 +301,6 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# images_query = """--sql
|
|
||||||
# SELECT * FROM images WHERE 1=1
|
|
||||||
# """
|
|
||||||
|
|
||||||
query_conditions = ""
|
query_conditions = ""
|
||||||
query_params = []
|
query_params = []
|
||||||
|
|
||||||
@ -320,7 +311,7 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
query_params.append(image_origin.value)
|
query_params.append(image_origin.value)
|
||||||
|
|
||||||
if categories is not None:
|
if categories is not None:
|
||||||
## Convert the enum values to unique list of strings
|
# Convert the enum values to unique list of strings
|
||||||
category_strings = list(map(lambda c: c.value, set(categories)))
|
category_strings = list(map(lambda c: c.value, set(categories)))
|
||||||
# Create the correct length of placeholders
|
# Create the correct length of placeholders
|
||||||
placeholders = ",".join("?" * len(category_strings))
|
placeholders = ",".join("?" * len(category_strings))
|
||||||
@ -344,6 +335,7 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
query_conditions += """--sql
|
query_conditions += """--sql
|
||||||
AND board_images.board_id = ?
|
AND board_images.board_id = ?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query_params.append(board_id)
|
query_params.append(board_id)
|
||||||
|
|
||||||
query_pagination = """--sql
|
query_pagination = """--sql
|
||||||
@ -457,7 +449,9 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
finally:
|
finally:
|
||||||
self._lock.release()
|
self._lock.release()
|
||||||
|
|
||||||
def get_most_recent_image_for_board(self, board_id: str) -> Union[ImageRecord, None]:
|
def get_most_recent_image_for_board(
|
||||||
|
self, board_id: str
|
||||||
|
) -> Union[ImageRecord, None]:
|
||||||
try:
|
try:
|
||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
self._cursor.execute(
|
self._cursor.execute(
|
||||||
|
Reference in New Issue
Block a user