"""ArtistVisit — per-artist 'last viewed' timestamp. Powers the "+N new since last visit" badge on the artists directory and the matching banner on `ArtistView`. One row per artist, single global operator. When the multi-user model lands, the PK widens to `(user_id, artist_id)` — currently aspirational only (no User model, no services/access.py); operator approved skipping `user_id` for now under rule #22 (breaking changes welcome). Seed at migration time: every existing artist gets `last_viewed_at = NOW()` so the badge starts at 0 across the board (no noisy "5000 unseen" on first deploy). New artists also auto-get a row via `ArtistService.find_or_create`. """ from datetime import datetime from sqlalchemy import DateTime, ForeignKey, Integer, func from sqlalchemy.orm import Mapped, mapped_column from .base import Base class ArtistVisit(Base): __tablename__ = "artist_visit" artist_id: Mapped[int] = mapped_column( Integer, ForeignKey("artist.id", ondelete="CASCADE"), primary_key=True, ) last_viewed_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), nullable=False, server_default=func.now(), )