feat: misc server updates (#1275)
This commit is contained in:
@@ -818,7 +818,10 @@ class SyncServer(LockingServer):
|
||||
return agent_config
|
||||
|
||||
# TODO make return type pydantic
|
||||
def list_agents(self, user_id: uuid.UUID) -> dict:
|
||||
def list_agents(
|
||||
self,
|
||||
user_id: uuid.UUID,
|
||||
) -> dict:
|
||||
"""List all available agents to a user"""
|
||||
if self.ms.get_user(user_id=user_id) is None:
|
||||
raise ValueError(f"User user_id={user_id} does not exist")
|
||||
@@ -873,6 +876,9 @@ class SyncServer(LockingServer):
|
||||
sources = [self.ms.get_source(source_id=s_id) for s_id in sources_ids]
|
||||
return_dict["sources"] = [vars(s) for s in sources]
|
||||
|
||||
# Sort agents by "last_run" in descending order, most recent first
|
||||
agents_states_dicts.sort(key=lambda x: x["last_run"], reverse=True)
|
||||
|
||||
logger.info(f"Retrieved {len(agents_states)} agents for user {user_id}:\n{[vars(s) for s in agents_states]}")
|
||||
return {
|
||||
"num_agents": len(agents_states),
|
||||
|
||||
Reference in New Issue
Block a user