feat(artist): "new since last visit" badge + banner #58

Merged
bvandeusen merged 2 commits from dev into main 2026-06-03 16:20:54 -04:00
Owner

Summary

Per-artist "+N" accent pill on the artists directory and a "N new since last visit" banner inside ArtistView. Counts new images (not posts) — multi-image posts increment correctly. The visit auto-marks on ArtistView open; no manual "mark as read" button.

  • alembic 0034artist_visit (artist_id PK, last_viewed_at NOT NULL). Seeds every existing artist with last_viewed_at = NOW() so the badge starts at 0 across the board (no noisy "5000 unseen" on first deploy).
  • ArtistService.find_or_create autoseeds a visit row alongside new artists, so freshly imported content doesn't read as unseen.
  • ArtistService.overview reads pre-visit last_viewed_at, counts images created since, then atomically UPSERTs last_viewed_at = NOW() via Postgres ON CONFLICT DO UPDATE (no SELECT-then-INSERT race). Returns unseen_count_at_visit in the response.
  • ArtistDirectoryService.list_artists adds an unseen_count aggregate per card via LEFT JOIN + conditional COUNT. NULL last_viewed_at defensively counts as "never visited".
  • Frontend: ArtistCard renders an accent pill in the preview-strip corner when unseen_count > 0 (capped at 99+); ArtistView shows a closable v-alert banner on initial load when unseen_count_at_visit > 0, re-arms on slug change.

Single-row-per-artist (no user_id) — rule #47 multi-user ACL is currently aspirational; widens to (user_id, artist_id) PK when User lands, per rule #22.

Test plan

  • tests/test_artist_visit.py — directory unseen_count math, NULL fallback, overview marks visit + returns count, repeat overview returns 0, find_or_create autoseed
  • tests/test_api_artists_directory.pyunseen_count added to pinned card-shape set
  • CI run 372 green on 3162cff across all 6 jobs
  • Operator UI: fresh deploy → badges start at 0. Wait for download → badge appears. Click artist → banner shows; badge clears.

Scribe plan #597 (done). Closes the "new since last visit" item in FC-4 (#490).

## Summary Per-artist "+N" accent pill on the artists directory and a "N new since last visit" banner inside `ArtistView`. Counts new **images** (not posts) — multi-image posts increment correctly. The visit auto-marks on `ArtistView` open; no manual "mark as read" button. - **alembic 0034** — `artist_visit (artist_id PK, last_viewed_at NOT NULL)`. Seeds every existing artist with `last_viewed_at = NOW()` so the badge starts at 0 across the board (no noisy "5000 unseen" on first deploy). - **ArtistService.find_or_create** autoseeds a visit row alongside new artists, so freshly imported content doesn't read as unseen. - **ArtistService.overview** reads pre-visit `last_viewed_at`, counts images created since, then atomically UPSERTs `last_viewed_at = NOW()` via Postgres `ON CONFLICT DO UPDATE` (no SELECT-then-INSERT race). Returns `unseen_count_at_visit` in the response. - **ArtistDirectoryService.list_artists** adds an `unseen_count` aggregate per card via LEFT JOIN + conditional COUNT. NULL `last_viewed_at` defensively counts as "never visited". - **Frontend**: `ArtistCard` renders an accent pill in the preview-strip corner when `unseen_count > 0` (capped at `99+`); `ArtistView` shows a closable v-alert banner on initial load when `unseen_count_at_visit > 0`, re-arms on slug change. Single-row-per-artist (no `user_id`) — rule #47 multi-user ACL is currently aspirational; widens to `(user_id, artist_id)` PK when User lands, per rule #22. ## Test plan - [x] `tests/test_artist_visit.py` — directory unseen_count math, NULL fallback, overview marks visit + returns count, repeat overview returns 0, find_or_create autoseed - [x] `tests/test_api_artists_directory.py` — `unseen_count` added to pinned card-shape set - [x] CI run 372 green on `3162cff` across all 6 jobs - [ ] Operator UI: fresh deploy → badges start at 0. Wait for download → badge appears. Click artist → banner shows; badge clears. Scribe plan #597 (done). Closes the "new since last visit" item in FC-4 (#490).
bvandeusen added 2 commits 2026-06-03 16:20:47 -04:00
feat(artist): "new since last visit" badge + banner
CI / lint (push) Failing after 2s
CI / backend-lint-and-test (push) Successful in 14s
CI / frontend-build (push) Successful in 22s
CI / intimp (push) Successful in 3m39s
CI / intapi (push) Failing after 7m41s
CI / intcore (push) Successful in 8m42s
b65e956ad2
Per-artist "+N" accent pill on the artists directory and a "N new since
last visit" banner inside ArtistView. Counts new IMAGES (not posts) so
multi-image posts increment correctly.

- alembic 0034: artist_visit (artist_id PK, last_viewed_at NOT NULL).
  Seeds every existing artist with last_viewed_at=NOW() so the badge
  starts at 0 across the board — no noisy "5000 unseen images" on
  first deploy.
- ArtistService.find_or_create autoseeds a visit row alongside new
  artists, so freshly imported content doesn't read as unseen.
- ArtistService.overview reads pre-visit last_viewed_at, counts images
  created since, then atomically UPSERTs last_viewed_at=NOW() via
  postgres ON CONFLICT DO UPDATE (no SELECT-then-INSERT race per
  reference_scalar_one_or_none_duplicates). Returns the pre-update
  count as `unseen_count_at_visit` so the banner has data.
- ArtistDirectoryService.list_artists adds an `unseen_count` aggregate
  to each card via LEFT JOIN artist_visit + conditional COUNT. NULL
  last_viewed_at (artist created before this code shipped) defensively
  counts as "never visited" → all images unseen.
- Frontend: ArtistCard renders an accent pill in the preview-strip
  corner when unseen_count > 0 (capped at 99+); ArtistView shows a
  closable v-alert banner on initial load when
  unseen_count_at_visit > 0, re-arms on slug change.

Single-row-per-artist (no user_id) — rule #47 multi-user ACL is
aspirational; widens to (user_id, artist_id) PK when User lands, per
rule #22.

Scribe plan #597.
fix(artist): ruff UP017 + test_directory_card_shape pin
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 27s
CI / backend-lint-and-test (push) Successful in 27s
CI / intimp (push) Successful in 3m29s
CI / intapi (push) Successful in 7m20s
CI / intcore (push) Successful in 8m4s
3162cff96b
Two CI bounces on b65e956:
1. ruff UP017 — Python 3.14's preferred form is `datetime.UTC`, not
   `timezone.utc`. Switch the test's two TZ literals.
2. test_directory_card_shape pinned the card key set to the pre-feature
   shape; `unseen_count` was added to the API payload but the pin
   wasn't updated. Same shape as the recurring 'plan-grep-pinned-tests'
   trap — should have grepped tests/ for card.keys() before pushing.
bvandeusen merged commit ab9922ad2e into main 2026-06-03 16:20:54 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bvandeusen/FabledCurator#58