This commit is contained in:
Tim Baek
2026-02-08 06:22:56 +04:00
parent 59b98ab730
commit 4852227158
8 changed files with 119 additions and 8 deletions
+15
View File
@@ -183,3 +183,18 @@ async def stop_item_tasks(redis: Redis, item_id: str):
return result # Return the first failure
return {"status": True, "message": f"All tasks for item {item_id} stopped."}
async def has_active_tasks(redis, chat_id: str) -> bool:
"""Check if a chat has any active tasks."""
task_ids = await list_task_ids_by_item_id(redis, chat_id)
return len(task_ids) > 0
async def get_active_chat_ids(redis, chat_ids: List[str]) -> List[str]:
"""Filter a list of chat_ids to only those with active tasks."""
active = []
for chat_id in chat_ids:
if await has_active_tasks(redis, chat_id):
active.append(chat_id)
return active