feat(people): add pagination support to getAllPeople endpoint

Support optional page, limit, and search query params.
Returns { data, total, page, totalPages } when paginated,
plain array for backward compatibility.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Mohammed AbadandCopilot committed 2026-04-27 13:29:16 +01:00
1 parent 8aca121b10
commit 6d676d803c
5 files changed
+57 -87

No files matched your search

-1
View File
@@ -67,7 +67,6 @@ Vault structure expectations:
- `docs-vault/Database.md` - `docs-vault/Database.md`
- `docs-vault/Deployment.md` - `docs-vault/Deployment.md`
- `docs-vault/Env.md` - `docs-vault/Env.md`
- `docs-vault/Changelog.md`
When updating documentation: When updating documentation:
+10 -1
View File
@@ -14,7 +14,16 @@ class PeopleController {
} }
async getAllPeople(req, res) { async getAllPeople(req, res) {
const people = await _peopleService.getAllPeople(); const { page, limit, search } = req.query;
const options = {};
if (page && limit) {
options.page = parseInt(page);
options.limit = parseInt(limit);
}
if (search) {
options.search = search;
}
const people = await _peopleService.getAllPeople(false, options);
res.status(200).json(people); res.status(200).json(people);
} }
+27 -3
View File
@@ -19,7 +19,7 @@ class PeopleService {
return PeopleService.instance; return PeopleService.instance;
} }
async getAllPeople(includeCrew = false) { async getAllPeople(includeCrew = false, { page, limit, search } = {}) {
let where = { let where = {
where: { where: {
cast_type: 'cast' cast_type: 'cast'
@@ -30,7 +30,13 @@ class PeopleService {
where = {}; where = {};
} }
const people = await People.findAll({ const peopleWhere = {};
if (search) {
peopleWhere.name = { [Op.like]: `%${search}%` };
}
const queryOptions = {
where: peopleWhere,
order: [["popularity", "DESC"]], order: [["popularity", "DESC"]],
include: [ include: [
{ {
@@ -45,8 +51,26 @@ class PeopleService {
}, },
{ model: Media, as: 'medias' } { model: Media, as: 'medias' }
], ],
}); };
// If pagination params provided, use findAndCountAll
if (page != null && limit != null) {
queryOptions.limit = limit;
queryOptions.offset = (page - 1) * limit;
queryOptions.distinct = true;
const { count, rows } = await People.findAndCountAll(queryOptions);
return {
data: rows,
total: count,
page,
totalPages: Math.ceil(count / limit),
};
}
// Legacy: return plain array for backward compat
const people = await People.findAll(queryOptions);
return people; return people;
} }
-79
View File
@@ -1,79 +0,0 @@
---
title: Changelog
tags:
- changelog
- milestones
---
# Changelog
All project milestones. See also `changes.md` in project root.
---
## Milestone 001
### Backend
- Added accuracy filter (`WHERE accuracy = 'EXACT'`) to [[Statistics]] watchday distribution queries in `statisticsController.js`
### Frontend
- Replaced Calendar popover with native `<input type="date">` in [[Watch Tracking|EntrySeenDialog]] and [[Watch Tracking|EpisodeSeenEditDialog]] for easier year selection
- Merged date + accuracy into a single row in both seen dialogs
- [[Statistics|LibraryGrowthChart]]: uses `createdAt` only (removed `date_first_seen`), includes all entries (watchlist + library)
- [[Pages|SeasonPage]] and [[Pages|EpisodePage]]: added `max-w-4xl` width constraint
- [[Navigation|Breadcrumbs]] now show "Title / Season x / Episode x" instead of generic labels
- 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
---
## Milestone 002
### Backend
- Added `favorite` and `pinned` boolean fields to [[Models#People|People]] model
- Added `entry_sync_status` field to [[Models#Entry|Entry]] model
- Added `searchPeople` method to [[Services|PeopleService]] for local DB search by name
- `fetchAndSavePersonByTmdbId` now accepts `options.pinned` for manual person adds
- Added orphan people cleanup to [[Services|MaintenanceService]]: finds people with no credits and not pinned
- Added `GET /maintenance/orphan-people` and `DELETE /maintenance/orphan-people` routes
- Added `markEntriesRequireCreditsSync()` to dataInitializer — marks entries needing credit sync
### Frontend
- [[Pages#SeasonPage|SeasonPage]]: Seen button always clickable (supports multiple seen records); shows seen dates with tooltip; improved mobile responsive layout
- [[Components|EntryCard]]: Quick actions dropdown menu (Favorite, Hide, Delete, Remove from collection); non-library entries now add to library + navigate instead of opening dialog
- [[Collections|CollectionDetailsPage]]: Remove entry from collection via quick actions menu
- [[People|PersonDetailsPage]]: Error handling for missing persons; favorite toggle button
- [[People|PeoplePage]]: Debounced search, Local DB toggle, All/Favorite filter
- [[Library|LibraryPage]]: Persistent filter/search/sort state via Zustand store (`useLibraryFiltersStore`)
- Added `useUpdatePerson`, `useSearchLocalPeople`, `useRemoveEntryFromCollection` [[Hooks|hooks]]
- Added `update`, `search` methods to [[API Clients|people.ts]]
- Added orphan people endpoints to [[API Clients|maintenance.ts]]
- [[Components|EntryCard]]: Moved quick actions to top-right icon button; added all Entry Details page actions (Mark watched, Rate, Watch History, Add to collection, Refresh, Manage media, Settings) with lazy-loaded dialogs
- [[Collections|CollectionDetailsPage]]: Added sort toolbar (Order, Year, Title, Rating) with asc/desc toggle
- **Backend**: Added `GET /entries/tmdb/preview/:type/:tmdbId` — TMDB preview endpoint (no library save)
- Created [[Pages#TmdbPreviewPage|TmdbPreviewPage]] — shows TMDB entry details with "Add to Library" button; TV series shows season/episode count
- [[Components|EntryCard]]: Non-library entries now navigate to TMDB preview page instead of auto-adding to library
- Added `TmdbPreview` type, `previewTmdb` API method, `useTmdbPreview` [[Hooks|hook]]
+20 -3
View File
@@ -41,12 +41,29 @@ See [[Models#People]] and [[Models#Credit]].
## Pages ## Pages
- [[Pages#PeoplePage|PeoplePage]] — Browse and search people - [[Pages#PeoplePage|PeoplePage]] — Browse and search people (server-side paginated, 48 per page)
- [[Pages#PersonDetailsPage|PersonDetailsPage]] — Full profile + filmography - [[Pages#PersonDetailsPage|PersonDetailsPage]] — Unified person page handling both local DB IDs (`/people/:id`) and TMDB IDs (`/people/tmdb/:tmdbId`)
- [[Pages#PersonTmdbRedirectPage|PersonTmdbRedirectPage]] — TMDB ID → local redirect
### PersonDetailsPage Modes
| Route | Mode | Data Source | Actions |
|---|---|---|---|
| `/people/:id` | Local DB | `GET /people/:id` + TMDB filmography | Favorite toggle |
| `/people/tmdb/:tmdbId` | TMDB Preview | `GET /people/tmdb/preview/:tmdbId` | Add to Library (saves with `pinned: true`) |
Both modes share the same `PersonMeta` component (shows department, birthday, place of birth, TMDB external link) and `FilmographySection` (splits credits into "In Library" / "Not in Library" with pagination).
## API Endpoints ## API Endpoints
### Pagination
`GET /people` now supports optional query params:
- `page` (number) — Page number (1-based)
- `limit` (number) — Items per page
- `search` (string) — Filter by name (LIKE match)
When `page` and `limit` are provided, returns `{ data, total, page, totalPages }`. Without them, returns a plain array for backward compatibility.
See [[API Reference#People]]. See [[API Reference#People]].
## Hooks ## Hooks