Add naming scheme selection to run configuration

Add a nullable naming_scheme column to NuzlockeRun so users can pick a
themed word category for nickname suggestions. Includes Alembic migration,
updated Pydantic schemas, a GET /runs/naming-categories endpoint backed by
a cached dictionary loader, and frontend dropdowns in both the NewRun
creation flow and the RunDashboard for mid-run changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 21:36:50 +01:00
parent e61fce5f72
commit e324559476
15 changed files with 215 additions and 31 deletions

View File

@@ -5,24 +5,32 @@ status: todo
type: task
priority: normal
created_at: 2026-02-11T15:56:44Z
updated_at: 2026-02-11T15:56:48Z
updated_at: 2026-02-11T20:23:35Z
parent: nuzlocke-tracker-igl3
blocking:
- nuzlocke-tracker-bi4e
---
Build the core logic that picks random name suggestions from the dictionary based on a selected naming scheme (category).
Build the backend service and API endpoint that picks random name suggestions from the dictionary based on a selected naming scheme.
## Requirements
- Given a category and a list of already-used names in the run, return 5-10 unique suggestions
- Suggestions must not include names already assigned to other Pokemon in the same run
- Given a category and a run ID, return 5-10 unique suggestions
- The engine queries the run's existing encounter nicknames and excludes them from suggestions
- Support regeneration (return a fresh batch, avoiding previously shown suggestions where possible)
- Handle edge case where category is nearly exhausted gracefully (return fewer suggestions)
## Implementation Notes
- **Backend service**: A Python module that loads the dictionary JSON, filters by category, excludes used names, and picks random suggestions.
- **API endpoint**: `GET /api/v1/runs/{run_id}/name-suggestions?count=10` — reads the run's `naming_scheme`, fetches encounter nicknames, returns suggestions.
- **No new DB tables needed**: Used names come from `Encounter.nickname` on the run's encounters.
- **Caching**: Load the dictionary once and cache in memory (it's static data).
## Checklist
- [ ] Create a service/utility module for name suggestion logic
- [ ] Create a service module for name suggestion logic (e.g. `services/name_suggestions.py`)
- [ ] Implement dictionary loading with in-memory caching
- [ ] Implement random selection from a category with exclusion of used names
- [ ] Implement regeneration that avoids repeating previous suggestions
- [ ] Add API endpoint for fetching suggestions
- [ ] Add unit tests for the suggestion logic