fix tasks command: show all tasks with statuses, not only todo
- solve_task: add fetch_all_tasks() for monitoring all task statuses - console.py: tasks command now uses fetch_all_tasks with formatted table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-3
@@ -17,7 +17,7 @@ os.environ["NO_PROXY"] = "openrouter.ai,platform.brojs.ru,git.brojs.ru," + os.en
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from solve_task import fetch_todo_tasks, solve, run_all
|
||||
from solve_task import fetch_todo_tasks, fetch_all_tasks, solve, run_all
|
||||
|
||||
HELP = """
|
||||
Команды:
|
||||
@@ -53,9 +53,15 @@ async def main():
|
||||
print(HELP)
|
||||
|
||||
elif cmd == "tasks":
|
||||
tasks = await fetch_todo_tasks()
|
||||
tasks = await fetch_all_tasks()
|
||||
if not tasks:
|
||||
print(" Нет активных заданий.")
|
||||
print(" Заданий не найдено.")
|
||||
else:
|
||||
print(f"\n {'ID':10} {'Статус':20} Название")
|
||||
print(f" {'-'*10} {'-'*20} {'-'*40}")
|
||||
for t in tasks:
|
||||
print(f" {t['id'][:8]}... {t['status']:20} {t['title']}")
|
||||
print()
|
||||
|
||||
elif cmd.startswith("solve "):
|
||||
task_id = cmd.split(" ", 1)[1].strip()
|
||||
|
||||
@@ -389,6 +389,29 @@ async def fetch_todo_tasks(course_id: str = COURSE_ID) -> list[tuple[str, str]]:
|
||||
return tasks
|
||||
|
||||
|
||||
async def fetch_all_tasks(course_id: str = COURSE_ID) -> list[dict]:
|
||||
"""Возвращает все задания курса с их статусами (для мониторинга)."""
|
||||
raw = await mcp_call("tasks_list", {"courseId": course_id})
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
return []
|
||||
items = data.get("tasks", data) if isinstance(data, dict) else data
|
||||
if not isinstance(items, list):
|
||||
return []
|
||||
result = []
|
||||
for item in items:
|
||||
t = item.get("task", item) if isinstance(item, dict) else {}
|
||||
tid = t.get("id", "")
|
||||
if tid:
|
||||
result.append({
|
||||
"id": tid,
|
||||
"title": t.get("title", t.get("name", "")),
|
||||
"status": item.get("status", ""),
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Полный автоматический прогон
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user