From 0459a1b4bf8d05d49bcbfcc33e70f76f725c5f80 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Fri, 29 May 2026 02:45:53 +0100 Subject: [PATCH] fix(ai-query): correct model column names for EntryRating, Collection, Media --- backend/controllers/aiQueryController.js | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/controllers/aiQueryController.js b/backend/controllers/aiQueryController.js index 556449c..d083d5e 100644 --- a/backend/controllers/aiQueryController.js +++ b/backend/controllers/aiQueryController.js @@ -54,7 +54,7 @@ class AiQueryController { model: Entry, as: 'entry', include: [ - { model: EntryRating, as: 'entryRating', attributes: ['userRating', 'tmdbRating', 'imdbRating', 'rottenTomatoesRating'] }, + { model: EntryRating, as: 'entryRating', attributes: ['user_rating', 'tmdb_rating', 'imdb_rating', 'rotten_tomatoes_rating'] }, { model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } } ], attributes: ['id', 'title', 'is_tvseries', 'poster_path', 'banner_path', 'runtime', 'release_date', 'favorit', 'watchlist'] @@ -149,7 +149,7 @@ class AiQueryController { const entries = await Entry.findAll({ where: { watchlist: true, hidden: false }, include: [ - { model: EntryRating, as: 'entryRating', attributes: ['userRating', 'tmdbRating', 'imdbRating', 'rottenTomatoesRating'] }, + { model: EntryRating, as: 'entryRating', attributes: ['user_rating', 'tmdb_rating', 'imdb_rating', 'rotten_tomatoes_rating'] }, { model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } } ], order: [['updatedAt', 'DESC']] @@ -164,7 +164,7 @@ class AiQueryController { const entries = await Entry.findAll({ where: { favorit: true, hidden: false }, include: [ - { model: EntryRating, as: 'entryRating', attributes: ['userRating', 'tmdbRating', 'imdbRating', 'rottenTomatoesRating'] }, + { model: EntryRating, as: 'entryRating', attributes: ['user_rating', 'tmdb_rating', 'imdb_rating', 'rotten_tomatoes_rating'] }, { model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } } ], order: [['updatedAt', 'DESC']] @@ -231,7 +231,7 @@ class AiQueryController { const entries = await Entry.findAll({ where, include: [ - { model: EntryRating, as: 'entryRating', attributes: ['userRating', 'tmdbRating', 'imdbRating', 'rottenTomatoesRating'] }, + { model: EntryRating, as: 'entryRating', attributes: ['user_rating', 'tmdb_rating', 'imdb_rating', 'rotten_tomatoes_rating'] }, { model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } } ], order: [['title', 'ASC']], @@ -321,7 +321,7 @@ class AiQueryController { { model: EntryRating, as: 'entryRating', attributes: { exclude: ['id', 'entry_id'] } }, { model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } }, { model: Network, as: 'networks', attributes: ['id', 'name'], through: { attributes: [] } }, - { model: Collection, as: 'collections', attributes: ['id', 'name', 'is_user_collection', 'description'], through: { attributes: [] } }, + { model: Collection, as: 'collections', attributes: ['id', 'name', 'isUserCollection', 'description'], through: { attributes: [] } }, { model: Credit, as: 'credits', limit: 20, include: [{ model: People, as: 'person', attributes: ['id', 'name', 'profile_path', 'known_for_department'] }] @@ -333,7 +333,7 @@ class AiQueryController { attributes: ['id', 'name', 'episode_number', 'runtime', 'air_date', 'still_path', 'overview'] }] }, - { model: Media, as: 'medias', where: { is_selected: true }, required: false } + { model: Media, as: 'medias', where: { isSelected: true }, required: false } ] }); @@ -383,7 +383,7 @@ class AiQueryController { getAllCollections = asyncWrapper(async (req, res) => { const collections = await Collection.findAll({ - attributes: ['id', 'name', 'description', 'is_user_collection', 'poster_path', 'backdrop_path'], + attributes: ['id', 'name', 'description', 'isUserCollection', 'posterPath', 'backdropPath'], include: [{ model: Entry, as: 'entries', @@ -398,9 +398,9 @@ class AiQueryController { id: c.id, name: c.name, description: c.description, - is_user_collection: c.is_user_collection, - poster_path: c.poster_path, - backdrop_path: c.backdrop_path, + is_user_collection: c.isUserCollection, + poster_path: c.posterPath, + backdrop_path: c.backdropPath, entry_count: c.entries.length }))); }); @@ -416,7 +416,7 @@ class AiQueryController { as: 'entries', through: { attributes: ['order'] }, include: [ - { model: EntryRating, as: 'entryRating', attributes: ['userRating', 'tmdbRating'] }, + { model: EntryRating, as: 'entryRating', attributes: ['user_rating', 'tmdb_rating'] }, { model: Genre, as: 'genres', attributes: ['name'], through: { attributes: [] } } ] }] @@ -443,7 +443,7 @@ class AiQueryController { include: [{ model: EpisodeSeen, as: 'episodeSeens', attributes: ['id'], required: false }] }] }, - { model: EntryRating, as: 'entryRating', attributes: ['userRating'] } + { model: EntryRating, as: 'entryRating', attributes: ['user_rating'] } ], distinct: true }); @@ -461,7 +461,7 @@ class AiQueryController { title: s.title, poster_path: s.poster_path, banner_path: s.banner_path, - user_rating: s.entryRating?.userRating || null, + user_rating: s.entryRating?.user_rating || null, total_episodes: totalEpisodes, seen_episodes: seenEpisodes, progress_pct: totalEpisodes > 0 ? Math.round((seenEpisodes / totalEpisodes) * 100) : 0,