feat: Add badge earned info to user profile badges API response #159

Merged
retoor merged 4 commits from typosaurus/157-add-badge-earned-info-to-user-profile-badges-api-response into master 2026-08-05 02:21:37 +02:00
2 changed files with 4 additions and 1 deletions
Showing only changes of commit 4bd420f38b - Show all commits

View File

@ -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)

View File

@ -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)