update
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user