feat(core): sort agents by updated_at [LET-7771] (#9730)
feat(core): sort agents by last_updated_at
This commit is contained in:
committed by
Caren Thomas
parent
c247496027
commit
c8ae02a1fb
@@ -4274,7 +4274,7 @@
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"enum": ["created_at", "last_run_completion"],
|
||||
"enum": ["created_at", "updated_at", "last_run_completion"],
|
||||
"type": "string",
|
||||
"description": "Field to sort by",
|
||||
"default": "created_at",
|
||||
|
||||
@@ -156,7 +156,7 @@ async def list_agents(
|
||||
order: Literal["asc", "desc"] = Query(
|
||||
"desc", description="Sort order for agents by creation time. 'asc' for oldest first, 'desc' for newest first"
|
||||
),
|
||||
order_by: Literal["created_at", "last_run_completion"] = Query("created_at", description="Field to sort by"),
|
||||
order_by: Literal["created_at", "updated_at", "last_run_completion"] = Query("created_at", description="Field to sort by"),
|
||||
ascending: bool = Query(
|
||||
False,
|
||||
description="Whether to sort agents oldest to newest (True) or newest to oldest (False, default)",
|
||||
|
||||
@@ -604,6 +604,9 @@ def _apply_pagination(
|
||||
if sort_by == "last_run_completion":
|
||||
sort_column = AgentModel.last_run_completion
|
||||
sort_nulls_last = True # TODO: handle this as a query param eventually
|
||||
elif sort_by == "updated_at":
|
||||
sort_column = AgentModel.updated_at
|
||||
sort_nulls_last = False
|
||||
else:
|
||||
sort_column = AgentModel.created_at
|
||||
sort_nulls_last = False
|
||||
@@ -637,6 +640,9 @@ async def _apply_pagination_async(
|
||||
if sort_by == "last_run_completion":
|
||||
sort_column = AgentModel.last_run_completion
|
||||
sort_nulls_last = True # TODO: handle this as a query param eventually
|
||||
elif sort_by == "updated_at":
|
||||
sort_column = AgentModel.updated_at
|
||||
sort_nulls_last = False
|
||||
else:
|
||||
sort_column = AgentModel.created_at
|
||||
sort_nulls_last = False
|
||||
|
||||
Reference in New Issue
Block a user