From 4bd420f38b5d0fe6c7b8de67ef81e3a4f280c3d1 Mon Sep 17 00:00:00 2001 From: typosaurus Date: Tue, 4 Aug 2026 16:38:35 +0000 Subject: [PATCH] feat(nadia): Add description to the badge dict and declare it on BadgeOut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Outcome: done Changed: devplacepy/routers/profile/index.py:204-208, devplacepy/schemas/content.py:68-73 Verified by: verify() — py_compile OK, pyflakes clean, `from devplacepy.main import app` imports clean, pytest tests/api/profile/index.py tests/unit/utils.py → 42 passed Findings: - Badge loop (devplacepy/routers/profile/index.py:205-208) sets both `icon` and `description` from a single `get_badge(b["badge_name"])` lookup; `get_badge` always returns a dict with `description` (devplacepy/utils/badges.py:105-108). - `BadgeOut` (devplacepy/schemas/content.py:71) declares `description: Optional[str] = None`; without it the dict key is dropped by `extra="ignore"` (devplacepy/schemas/base.py:10-11). BadgeOut is consumed only by ProfileOut (devplacepy/schemas/profile.py:32). - Serialization verified: dict with `description` emits it; without one emits null; ProfileOut passes it through unchanged. - Environment: workspace Python is 3.11.2, pyproject requires >=3.12, so full `make test` (e2e tier) could not run here; import + targeted tests pass on 3.11. - 25 pre-existing tests/unit failures (e.g. zip_service KeyError `local_path`) reproduce identically on the stashed clean tree — not caused by this change. - Direct pytest writes `__pycache__` (make exports PYTHONDONTWRITEBYTECODE=1); after a byte-level edit this caused a transient `cannot import name 'AttachmentOut'` in the uvicorn subprocess, gone after removing `__pycache__` — run tests via make targets. Open: test extension asse Typosaurus-Run: 3828c0c223934696842a70e9d9efb9e0 Typosaurus-Node: 527d1bad2be4464b886a71af0247378e Typosaurus-Agent: @nadia Refs: #157 --- devplacepy/routers/profile/index.py | 4 +++- devplacepy/schemas/content.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/devplacepy/routers/profile/index.py b/devplacepy/routers/profile/index.py index 26484688..90c09a0c 100644 --- a/devplacepy/routers/profile/index.py +++ b/devplacepy/routers/profile/index.py @@ -203,7 +203,9 @@ async def profile_page( badges = list(get_table("badges").find(user_uid=profile_user["uid"])) for b in badges: - b["icon"] = get_badge(b["badge_name"]).get("icon") + badge_meta = get_badge(b["badge_name"]) + b["icon"] = badge_meta.get("icon") + b["description"] = badge_meta.get("description") achievements = build_achievements({b["badge_name"] for b in badges}) badge_total = sum(group["total"] for group in achievements) badge_earned = sum(group["earned"] for group in achievements) diff --git a/devplacepy/schemas/content.py b/devplacepy/schemas/content.py index fe370a4e..8f8c79a1 100644 --- a/devplacepy/schemas/content.py +++ b/devplacepy/schemas/content.py @@ -68,6 +68,7 @@ class PollOut(_Out): class BadgeOut(_Out): name: Optional[str] = Field(None, alias="badge_name") icon: Optional[str] = None + description: Optional[str] = None created_at: Optional[str] = None model_config = ConfigDict(populate_by_name=True)