Update schema (devplacepy/schemas/content.py lines 68–71)
Add icon: Optional[str] = None to BadgeOut. No other fields or aliases needed.
Enrich badge rows in profile route (devplacepy/routers/profile/index.py around line 203)
After the list(get_table("badges").find(...)) call (line 203) and before the response context is built, insert a loop:
The get_badge function is already imported (used elsewhere). This makes icon available in each row dict so BadgeOut serializes it into JSON.
(Optional) Add API test (tests/api/profile/index.py)
Add a test that fetches a profile with Accept: application/json and asserts every badge in the response has an icon field (non‑empty string). This is recommended but not mandatory for the fix.
Run verification
Execute the project’s test command targeting relevant test files:
Profile route handler enriches each badge dict with icon from the catalog before response serialization.
JSON response for profile endpoint includes icon for every badge (verified via a new or existing API test).
All unit and API tests (tests/api/profile/index.py, tests/unit/utils.py) pass with exit code 0.
No database migrations or template changes required.
Existing HTML profile rendering remains unchanged.
Opened automatically by Typosaurus.
Resolves #146.
## Plan
**Plan: Add `icon` field to badge API response**
1. **Update schema** (`devplacepy/schemas/content.py` lines 68–71)
Add `icon: Optional[str] = None` to `BadgeOut`. No other fields or aliases needed.
2. **Enrich badge rows in profile route** (`devplacepy/routers/profile/index.py` around line 203)
After the `list(get_table("badges").find(...))` call (line 203) and before the response context is built, insert a loop:
```python
for b in badges:
b["icon"] = get_badge(b["badge_name"])["icon"]
```
The `get_badge` function is already imported (used elsewhere). This makes `icon` available in each row dict so `BadgeOut` serializes it into JSON.
3. **(Optional) Add API test** (`tests/api/profile/index.py`)
Add a test that fetches a profile with `Accept: application/json` and asserts every badge in the response has an `icon` field (non‑empty string). This is recommended but not mandatory for the fix.
4. **Run verification**
Execute the project’s test command targeting relevant test files:
```
pip install -e '.[dev]' -q && python -m pytest tests/api/profile/index.py tests/unit/utils.py
```
Do not include e2e tests (known flakiness unrelated to this change).
---
**Definition of Done**
- `BadgeOut` schema contains `icon: Optional[str] = None`.
- Profile route handler enriches each badge dict with `icon` from the catalog before response serialization.
- JSON response for profile endpoint includes `icon` for every badge (verified via a new or existing API test).
- All unit and API tests (`tests/api/profile/index.py`, `tests/unit/utils.py`) pass with exit code 0.
- No database migrations or template changes required.
- Existing HTML profile rendering remains unchanged.
Opened automatically by Typosaurus.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Resolves #146.
Plan
Plan: Add
iconfield to badge API responseUpdate schema (
devplacepy/schemas/content.pylines 68–71)Add
icon: Optional[str] = NonetoBadgeOut. No other fields or aliases needed.Enrich badge rows in profile route (
devplacepy/routers/profile/index.pyaround line 203)After the
list(get_table("badges").find(...))call (line 203) and before the response context is built, insert a loop:The
get_badgefunction is already imported (used elsewhere). This makesiconavailable in each row dict soBadgeOutserializes it into JSON.(Optional) Add API test (
tests/api/profile/index.py)Add a test that fetches a profile with
Accept: application/jsonand asserts every badge in the response has aniconfield (non‑empty string). This is recommended but not mandatory for the fix.Run verification
Execute the project’s test command targeting relevant test files:
Do not include e2e tests (known flakiness unrelated to this change).
Definition of Done
BadgeOutschema containsicon: Optional[str] = None.iconfrom the catalog before response serialization.iconfor every badge (verified via a new or existing API test).tests/api/profile/index.py,tests/unit/utils.py) pass with exit code 0.Opened automatically by Typosaurus.