This commit is contained in:
team3
2026-07-04 03:25:02 +02:00
parent c4caf31ed0
commit 2f5d5b9ca1
11 changed files with 176 additions and 18 deletions

View File

@@ -60,16 +60,19 @@ _LEVELS_OK = ("beginner", "advanced", "expert", "easy", "medium", "hard")
async def _load_subblocks(topic: str) -> dict[str, list[dict]]:
"""Subblocks per block — DB-first ({title, level, relevance}), fallback sidecar file.
Both missing → {} (guide takes everything)."""
Both missing → {} (guide takes everything). A missing/invalid level defaults to
'advanced' instead of dropping the row: re-run resume left 25 consensus subs
level-less, the writer silently lost them while the guide QA still counted them."""
out: dict[str, list[dict]] = {}
for r in await list_subblocks(topic):
if r["status"] == "consensus" and r["sub_title"] and r["level"] in _LEVELS_OK:
if r["status"] == "consensus" and r["sub_title"]:
try:
facts = json.loads(r["facts"]) if r.get("facts") else {}
except (ValueError, TypeError):
facts = {}
level = r["level"] if r["level"] in _LEVELS_OK else "advanced"
out.setdefault(r["block"], []).append(
{"title": r["sub_title"], "level": r["level"], "relevance": r["relevance"], "facts": facts})
{"title": r["sub_title"], "level": level, "relevance": r["relevance"], "facts": facts})
if out:
return out
data = _json_file(subblocks_path(topic))