Parameter search & inline display for Past Runs and Run History pages (#3985)
This commit is contained in:
@@ -2379,6 +2379,7 @@ class AgentDB:
|
||||
page_size: int = 10,
|
||||
status: list[WorkflowRunStatus] | None = None,
|
||||
include_debugger_runs: bool = False,
|
||||
search_key: str | None = None,
|
||||
) -> list[WorkflowRun | Task]:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
@@ -2398,6 +2399,28 @@ class AgentDB:
|
||||
if not include_debugger_runs:
|
||||
workflow_run_query = workflow_run_query.filter(WorkflowRunModel.debug_session_id.is_(None))
|
||||
|
||||
if search_key:
|
||||
key_like = f"%{search_key}%"
|
||||
param_exists = exists(
|
||||
select(1)
|
||||
.select_from(WorkflowRunParameterModel)
|
||||
.join(
|
||||
WorkflowParameterModel,
|
||||
WorkflowParameterModel.workflow_parameter_id
|
||||
== WorkflowRunParameterModel.workflow_parameter_id,
|
||||
)
|
||||
.where(WorkflowRunParameterModel.workflow_run_id == WorkflowRunModel.workflow_run_id)
|
||||
.where(WorkflowParameterModel.deleted_at.is_(None))
|
||||
.where(
|
||||
or_(
|
||||
WorkflowParameterModel.key.ilike(key_like),
|
||||
WorkflowParameterModel.description.ilike(key_like),
|
||||
WorkflowRunParameterModel.value.ilike(key_like),
|
||||
)
|
||||
)
|
||||
)
|
||||
workflow_run_query = workflow_run_query.where(param_exists)
|
||||
|
||||
if status:
|
||||
workflow_run_query = workflow_run_query.filter(WorkflowRunModel.status.in_(status))
|
||||
workflow_run_query = workflow_run_query.order_by(WorkflowRunModel.created_at.desc()).limit(limit)
|
||||
|
||||
@@ -1857,6 +1857,10 @@ async def get_runs(
|
||||
page: int = Query(1, ge=1),
|
||||
page_size: int = Query(10, ge=1),
|
||||
status: Annotated[list[WorkflowRunStatus] | None, Query()] = None,
|
||||
search_key: str | None = Query(
|
||||
None,
|
||||
description="Search runs by parameter key, parameter description, or run parameter value.",
|
||||
),
|
||||
) -> Response:
|
||||
analytics.capture("skyvern-oss-agent-runs-get")
|
||||
|
||||
@@ -1864,7 +1868,9 @@ async def get_runs(
|
||||
if page > 10:
|
||||
return []
|
||||
|
||||
runs = await app.DATABASE.get_all_runs(current_org.organization_id, page=page, page_size=page_size, status=status)
|
||||
runs = await app.DATABASE.get_all_runs(
|
||||
current_org.organization_id, page=page, page_size=page_size, status=status, search_key=search_key
|
||||
)
|
||||
return ORJSONResponse([run.model_dump() for run in runs])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user