fix(backend): include EpisodeSeen in season episodes and add entry credits endpoint

- Add getEntryCredits service method returning all cast + crew with People, ordered by cast_type, order, episode_count
- Add getEntryCredits controller method
- Add GET /entries/:id/credits route in entry.routes.js
- Include EpisodeSeen association in getSeasonEpisodes so seen dates are returned to frontend
This commit is contained in:
Mohammed Abad committed 2026-04-29 16:04:10 +01:00
1 parent e460290b9b
commit 22d111ef71
7 files changed
+51 -3

No files matched your search

+31 -1
View File
@@ -118,6 +118,36 @@ class EntryService {
return entry;
}
/**
* Retrieves ALL credits (cast + crew) for an entry with associated people.
* Used by the Cast & Crew page to lazy-render large credit lists.
*
* @param {number} id - The entry ID.
* @returns {Promise<Array>} Array of plain credit objects with `people` populated.
*/
async getEntryCredits(id) {
if (!id) {
throw new BadRequestError("Entry id not provided");
}
const entry = await Entry.findByPk(id, { attributes: ['id'] });
if (!entry) {
throw new NotFoundError("Entry with the provided id was not found");
}
const credits = await Credit.findAll({
where: { entry_id: id },
include: [{ model: People, as: 'person' }],
order: [
['cast_type', 'ASC'],
['order', 'ASC'],
['episode_count', 'DESC'],
],
});
return credits.map(c => c.get({ plain: true }));
}
async createEntry(data, plain = true) {
// creating the object
var is_tvseries = data.release_date == null ? true : false;
@@ -454,4 +484,4 @@ class EntryService {
}
module.exports = new EntryService();
module.exports = new EntryService();