Skip to content

Add age rating browser filters and rename FTS age_rating column#565

Merged
ajslater merged 1 commit intoage-filterfrom
claude/goofy-benz-629f08
Apr 21, 2026
Merged

Add age rating browser filters and rename FTS age_rating column#565
ajslater merged 1 commit intoage-filterfrom
claude/goofy-benz-629f08

Conversation

@ajslater
Copy link
Copy Markdown
Owner

Summary

Adds two browser filter options — Age Rating (the normalized metron_age_rating) and Age Rating (Tagged) (the original age_rating FK) — and reworks the FTS schema so the two ratings are indexed separately.

  • Browser filters: metron_age_rating is registered in BROWSER_FILTER_KEYS, filter serializers, and the frontend filter sub-menu (with a FILTER_TITLE_OVERRIDES map so the two rating fields render as Age Rating and Age Rating (Tagged)).
  • FTS rename + add: ComicFTS.age_rating column is renamed to tagged_age_rating; a new metron_age_rating FTS column is added. The search aliases age and age_rating now map to metron_age_rating (not to the tagged rating).
  • Importer: metron_age_rating is removed from NON_FTS_FIELDS so the Comic CharField flows into FTS. An FTS_FIELD_RENAME_MAP redirects the age_rating FK's linked name to tagged_age_rating at FTS-write sites.
  • Migration 0040: adds SettingsBrowserFilters.metron_age_rating JSONField and drops + recreates the codex_comicfts virtual FTS5 table with the new schema (repopulated on the next librarian sync).
  • Importer test fixtures updated for the new FTS key layout.

Test plan

  • uv run python -m codex.manage makemigrations --check codex — clean
  • uv run python -m codex.manage migrate0040_fts_age_rating applied; FTS virtual table schema verified via dbshell
  • make fix-python / make lint-python — clean (ruff, basedpyright, vulture, complexipy, codespell)
  • uv run pytest — 5 passed (all 3 previously-failing importer tests now green)
  • Manual: Browser "filter by" menu shows both Age Rating and Age Rating (Tagged); each filters correctly
  • Manual: Full-text search for age:Teen / age_rating:Teen hits metron_age_rating; tagged_age_rating:<value> hits the original FK name

🤖 Generated with Claude Code

Adds two new browser filter options ("Age Rating" for the normalized
metron_age_rating and "Age Rating (Tagged)" for the original age_rating FK)
and reworks the FTS schema so the two age ratings are indexed separately.

- Rename the ComicFTS age_rating column to tagged_age_rating and add a
  new metron_age_rating column. Search aliases "age" and "age_rating" now
  map to metron_age_rating; tagged_age_rating is keyed-only.
- Register metron_age_rating in BROWSER_FILTER_KEYS and the filter/choice
  serializers so the frontend menu surfaces it automatically. Frontend
  filter sub-menu adds an FILTER_TITLE_OVERRIDES map so the two ratings
  render as "Age Rating" and "Age Rating (Tagged)".
- Importer: drop metron_age_rating from NON_FTS_FIELDS so the plain
  CharField flows into FTS, and apply FTS_FIELD_RENAME_MAP when writing
  the age_rating FK's linked name to FTS so it lands under
  tagged_age_rating.
- Migration 0040: add SettingsBrowserFilters.metron_age_rating JSONField
  and drop+recreate the codex_comicfts virtual table with the new schema
  (it is rebuilt on the next librarian sync).
- Update importer test fixtures to reflect the new FTS key layout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ajslater ajslater merged commit 30f3211 into age-filter Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant