- Extends GET /api/v1/tags with sort=count_desc and min_count query params - New TagsComponent at /tags (public, no auth guard) shows all tags sorted by image count - Clicking a tag navigates to /?tags=<name> for a pre-filtered library view - LibraryComponent reads ?tags= query param on init to support deep-linking from tag browser - Library header gains a "Browse tags" link to /tags for discoverability - All 15 TDD tasks complete; ruff, ng lint, and ng build clean Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1020 B
1020 B
Data Model: Tag Browser
No schema changes are required for this feature. All data needed to power the tag browser already exists.
Derived Entity: Tag with Count
The tag browser displays a read-only, derived view of existing data:
| Field | Source | Notes |
|---|---|---|
name |
tags.name |
Lowercase, normalised string |
image_count |
COUNT(image_tags.image_id) WHERE image_tags.tag_id = tags.id |
Computed at query time |
This is exactly the shape already returned by GET /api/v1/tags as {"id", "name", "image_count"}.
What Changes
The query in TagRepository.list_tags() gains two optional behaviours:
- Sort by count descending — adds
ORDER BY image_count DESC, name ASC(count-desc primary, alphabetical secondary) instead of the currentORDER BY name ASC. - Exclude zero-count tags — adds
HAVING image_count > 0(or equivalentWHEREon the subquery) whenmin_count=1is requested.
No new tables, columns, indexes, or migrations are needed.