Skip to content

Commit acfeb4a

Browse files
Mary Hippmaryhipp
authored andcommitted
undo changes that made category optional
1 parent b33dbfc commit acfeb4a

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

invokeai/app/api/routers/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def list_workflows(
8888
default=WorkflowRecordOrderBy.Name, description="The attribute to order by"
8989
),
9090
direction: SQLiteDirection = Query(default=SQLiteDirection.Ascending, description="The direction to order by"),
91-
category: Optional[WorkflowCategory] = Query(default=None, description="The category of workflow to get"),
91+
category: WorkflowCategory = Query(default=WorkflowCategory.User, description="The category of workflow to get"),
9292
query: Optional[str] = Query(default=None, description="The text to query by (matches name and description)"),
9393
) -> PaginatedResults[WorkflowRecordListItemDTO]:
9494
"""Gets a page of workflows"""

invokeai/app/services/workflow_records/workflow_records_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def get_many(
4141
self,
4242
order_by: WorkflowRecordOrderBy,
4343
direction: SQLiteDirection,
44+
category: WorkflowCategory,
4445
page: int,
4546
per_page: Optional[int],
46-
category: Optional[WorkflowCategory],
4747
query: Optional[str],
4848
) -> PaginatedResults[WorkflowRecordListItemDTO]:
4949
"""Gets many workflows."""

invokeai/app/services/workflow_records/workflow_records_sqlite.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,17 @@ def get_many(
127127
self,
128128
order_by: WorkflowRecordOrderBy,
129129
direction: SQLiteDirection,
130+
category: WorkflowCategory,
130131
page: int = 0,
131132
per_page: Optional[int] = None,
132-
category: Optional[WorkflowCategory] = None,
133133
query: Optional[str] = None,
134134
) -> PaginatedResults[WorkflowRecordListItemDTO]:
135135
try:
136136
self._lock.acquire()
137137
# sanitize!
138138
assert order_by in WorkflowRecordOrderBy
139139
assert direction in SQLiteDirection
140+
assert category in WorkflowCategory
140141
count_query = "SELECT COUNT(*) FROM workflow_library"
141142
main_query = """
142143
SELECT
@@ -148,26 +149,16 @@ def get_many(
148149
updated_at,
149150
opened_at
150151
FROM workflow_library
152+
WHERE category = ?
151153
"""
152-
main_params: list[int | str] = []
153-
count_params: list[int | str] = []
154-
155-
if category:
156-
assert category in WorkflowCategory
157-
main_query += " WHERE category = ?"
158-
count_query += " WHERE category = ?"
159-
main_params.append(category.value)
160-
count_params.append(category.value)
154+
main_params: list[int | str] = [category.value]
155+
count_params: list[int | str] = [category.value]
161156

162157
stripped_query = query.strip() if query else None
163158
if stripped_query:
164159
wildcard_query = "%" + stripped_query + "%"
165-
if "WHERE" in main_query:
166-
main_query += " AND (name LIKE ? OR description LIKE ?)"
167-
count_query += " AND (name LIKE ? OR description LIKE ?)"
168-
else:
169-
main_query += " WHERE name LIKE ? OR description LIKE ?"
170-
count_query += " WHERE name LIKE ? OR description LIKE ?"
160+
main_query += " AND name LIKE ? OR description LIKE ? "
161+
count_query += " AND name LIKE ? OR description LIKE ?;"
171162
main_params.extend([wildcard_query, wildcard_query])
172163
count_params.extend([wildcard_query, wildcard_query])
173164

invokeai/frontend/web/src/services/api/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20050,7 +20050,7 @@ export interface operations {
2005020050
/** @description The direction to order by */
2005120051
direction?: components["schemas"]["SQLiteDirection"];
2005220052
/** @description The category of workflow to get */
20053-
category?: components["schemas"]["WorkflowCategory"] | null;
20053+
category?: components["schemas"]["WorkflowCategory"];
2005420054
/** @description The text to query by (matches name and description) */
2005520055
query?: string | null;
2005620056
};

0 commit comments

Comments
 (0)