Add a title search parameter to workflows endpoint, add index to work… (#1638)
Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
@@ -1176,6 +1176,7 @@ class AgentDB:
|
||||
page_size: int = 10,
|
||||
only_saved_tasks: bool = False,
|
||||
only_workflows: bool = False,
|
||||
title: str = "",
|
||||
) -> list[Workflow]:
|
||||
"""
|
||||
Get all workflows with the latest version for the organization.
|
||||
@@ -1209,6 +1210,8 @@ class AgentDB:
|
||||
main_query = main_query.where(WorkflowModel.is_saved_task.is_(True))
|
||||
elif only_workflows:
|
||||
main_query = main_query.where(WorkflowModel.is_saved_task.is_(False))
|
||||
if title:
|
||||
main_query = main_query.where(WorkflowModel.title.ilike(f"%{title}%"))
|
||||
main_query = (
|
||||
main_query.order_by(WorkflowModel.created_at.desc()).limit(page_size).offset(db_page * page_size)
|
||||
)
|
||||
|
||||
@@ -194,6 +194,7 @@ class WorkflowModel(Base):
|
||||
name="uc_org_permanent_id_version",
|
||||
),
|
||||
Index("permanent_id_version_idx", "workflow_permanent_id", "version"),
|
||||
Index("organization_id_title_idx", "organization_id", "title"),
|
||||
)
|
||||
|
||||
workflow_id = Column(String, primary_key=True, index=True, default=generate_workflow_id)
|
||||
|
||||
@@ -911,6 +911,7 @@ async def get_workflows(
|
||||
page_size: int = Query(10, ge=1),
|
||||
only_saved_tasks: bool = Query(False),
|
||||
only_workflows: bool = Query(False),
|
||||
title: str = Query(""),
|
||||
current_org: Organization = Depends(org_auth_service.get_current_org),
|
||||
) -> list[Workflow]:
|
||||
"""
|
||||
@@ -930,6 +931,7 @@ async def get_workflows(
|
||||
page_size=page_size,
|
||||
only_saved_tasks=only_saved_tasks,
|
||||
only_workflows=only_workflows,
|
||||
title=title,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -524,6 +524,7 @@ class WorkflowService:
|
||||
page_size: int = 10,
|
||||
only_saved_tasks: bool = False,
|
||||
only_workflows: bool = False,
|
||||
title: str = "",
|
||||
) -> list[Workflow]:
|
||||
"""
|
||||
Get all workflows with the latest version for the organization.
|
||||
@@ -534,6 +535,7 @@ class WorkflowService:
|
||||
page_size=page_size,
|
||||
only_saved_tasks=only_saved_tasks,
|
||||
only_workflows=only_workflows,
|
||||
title=title,
|
||||
)
|
||||
|
||||
async def update_workflow(
|
||||
|
||||
Reference in New Issue
Block a user