feat(backend): fix credit duplicates, support multi-role TV credits, fix collection upload

- Fix credit dedup key to people_id + cast_type (scoped to entry_id)
- Detect aggregate_credits format via Array.isArray(c.roles) instead of is_tvseries flag
- Join multiple roles/jobs with "; " instead of taking only the first
- Add episode_count field to Credit model from total_episode_count
- Increase character and job columns to VARCHAR(500)
- Deselect existing collection posters/backdrops before inserting new upload
- Updated docs-vault
- Updated some agents files
This commit is contained in:
Mohammed Abad committed 2026-04-23 16:51:18 +01:00
1 parent 260282a0e2
commit ce01dc34fa
14 files changed
+293 -45

No files matched your search

+18
View File
@@ -27,3 +27,21 @@ All project milestones. See also `changes.md` in project root.
- Fixed EpisodePage using `seasonId` (DB id) instead of `season.season_number` for display
- Added cleanup section to [[Settings Page]] for orphan files/media records
- Created [[API Clients|maintenance.ts]] API client
---
## Milestone 001.1
### Backend
- Fixed [[People|credit]] duplicate bug: changed dedup key from `people_id + cast_type + tmdb_credit_id` to `people_id + cast_type` — TV series credits no longer re-inserted on every refresh
- Fixed TV series character/job extraction: detects `aggregate_credits` format via `Array.isArray(c.roles)` instead of `is_tvseries` flag; joins all roles/jobs with `"; "`
- Added `episode_count` field to [[Models#Credit|Credit]] model (from TMDB `total_episode_count`)
- Increased `character` and `job` columns from `VARCHAR(100)` to `VARCHAR(500)` for multiple roles
- Fixed [[Collections|collection]] media upload: deselects existing posters/backdrops before inserting new custom upload
### Frontend
- Created [[Components#Dialogs|MarkSeasonWatchedDialog]] — dedicated dialog replacing the old two-step EpisodeSeenEditDialog + ConfirmDialog flow
- Added **Scatter Mode**: distributes episodes across a date range with even spread and live preview
- "Mark Season Watched" button on [[Pages#SeasonPage|SeasonPage]] is now always visible
+3
View File
@@ -41,6 +41,9 @@ Users can create custom collections:
- Poster and backdrop (upload via multipart)
- Add/remove entries, reorder
> [!info] Media Upload Behavior
> When a new poster or backdrop is uploaded for a collection, all existing media of the same type are deselected (`isSelected = false`) before the new one is created with `isSelected = true`. This ensures only the latest upload is active.
## API Endpoints
See [[API Reference#Collections]].
+1
View File
@@ -64,6 +64,7 @@ See [[Statistics]] for data details.
| `ConfirmDialog` | `dialogs/ConfirmDialog.tsx` | Generic confirmation dialog |
| `AddEntryToCollectionDialog` | `dialogs/AddEntryToCollectionDialog.tsx` | Add entry to collection picker |
| `CollectionEditDialog` | `dialogs/CollectionEditDialog.tsx` | Create/edit collection |
| `MarkSeasonWatchedDialog` | `dialogs/MarkSeasonWatchedDialog.tsx` | Mark season as watched — single date or scatter mode |
## Skeletons
+6 -2
View File
@@ -219,14 +219,18 @@ Join table for Collection ↔ Entry (M:N). Managed by hooks in `sequelizeHooks.j
| `tmdb_credit_id` | STRING(100) | |
| `adult` | BOOLEAN | Default `false` |
| `profile_path` | STRING(200) | TMDB profile image |
| `character` | STRING(100) | Role name (for cast) |
| `character` | STRING(500) | Role name(s) for cast — multiple roles joined by `"; "` |
| `order` | INTEGER | Display order |
| `episode_count` | INTEGER | Total episode count (from TMDB aggregate_credits) |
| `cast_type` | ENUM | `'cast'`, `'crew'`. Default `'cast'` |
| `department` | STRING(100) | For crew |
| `job` | STRING(100) | For crew |
| `job` | STRING(500) | Job title(s) for crew — multiple jobs joined by `"; "` |
| `entry_id` | INTEGER FK | → Entry |
| `people_id` | INTEGER FK | → People |
> [!info] TV Series Credits
> For TV series, TMDB returns `aggregate_credits` where a person can have multiple roles/jobs. These are joined with `"; "` into the `character` and `job` fields respectively. `episode_count` tracks the total episodes the person appeared in.
---
## People
+3 -1
View File
@@ -75,7 +75,9 @@ Season detail with episode list. Width: `max-w-4xl`.
- Breadcrumb: `Title / Season x` (see [[Navigation]])
- Episode progress bar
- Mark-all-as-seen action
- **Mark Season Watched** button (always visible) → opens [[Components#Dialogs|MarkSeasonWatchedDialog]]
- **Single Date mode**: marks all unwatched episodes on one date
- **Scatter Mode**: distributes episodes evenly across a date range (start → end)
- Episode list with watch status
- Links to EpisodePage
+5 -2
View File
@@ -33,8 +33,11 @@ See [[Models#People]] and [[Models#Credit]].
| `cast_type` | Fields Used |
|---|---|
| `cast` | `character`, `order` |
| `crew` | `department`, `job` |
| `cast` | `character`, `order`, `episode_count` |
| `crew` | `department`, `job`, `episode_count` |
> [!info] Multiple Roles
> For TV series (using TMDB `aggregate_credits`), a person may have multiple roles or jobs. These are stored joined by `"; "` in the `character` (cast) or `job` (crew) fields. The `episode_count` field tracks total episodes across all roles/jobs.
## Pages
+11 -5
View File
@@ -58,13 +58,19 @@ See [[API Reference#Entry Seen (Movie Watch Records)]] and [[API Reference#Episo
## Batch Operations
### Mark All Seen (Season)
### Mark Season Watched
The [[Pages#SeasonPage|SeasonPage]] has a "Mark All as Seen" action that:
The [[Pages#SeasonPage|SeasonPage]] has a "Mark Season Watched" button (always visible) that opens the [[Components#Dialogs|MarkSeasonWatchedDialog]]. Two modes:
1. Filters unwatched episodes
2. Creates an `EpisodeSeen` for each
3. Uses the selected date and accuracy
#### Single Date Mode
1. User picks a single date, accuracy, and optional "seen with"
2. All unwatched episodes are marked as seen on that date
#### Scatter Mode
1. User toggles scatter mode and picks a start date and end date
2. Episodes are distributed evenly across the date range
3. A preview shows total days and max episodes/day
4. Each episode gets a different `date_seen` based on the distribution
## Side Effects