fix(ai-query): correct model column names for EntryRating, Collection, Media
This commit is contained in:
1 parent
88ada32064
commit
0459a1b4bf
1 file changed
+13
-13
@@ -54,7 +54,7 @@ class AiQueryController {
|
|||||||
model: Entry,
|
model: Entry,
|
||||||
as: 'entry',
|
as: 'entry',
|
||||||
include: [
|
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: [] } }
|
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } }
|
||||||
],
|
],
|
||||||
attributes: ['id', 'title', 'is_tvseries', 'poster_path', 'banner_path', 'runtime', 'release_date', 'favorit', 'watchlist']
|
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({
|
const entries = await Entry.findAll({
|
||||||
where: { watchlist: true, hidden: false },
|
where: { watchlist: true, hidden: false },
|
||||||
include: [
|
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: [] } }
|
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } }
|
||||||
],
|
],
|
||||||
order: [['updatedAt', 'DESC']]
|
order: [['updatedAt', 'DESC']]
|
||||||
@@ -164,7 +164,7 @@ class AiQueryController {
|
|||||||
const entries = await Entry.findAll({
|
const entries = await Entry.findAll({
|
||||||
where: { favorit: true, hidden: false },
|
where: { favorit: true, hidden: false },
|
||||||
include: [
|
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: [] } }
|
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } }
|
||||||
],
|
],
|
||||||
order: [['updatedAt', 'DESC']]
|
order: [['updatedAt', 'DESC']]
|
||||||
@@ -231,7 +231,7 @@ class AiQueryController {
|
|||||||
const entries = await Entry.findAll({
|
const entries = await Entry.findAll({
|
||||||
where,
|
where,
|
||||||
include: [
|
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: [] } }
|
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } }
|
||||||
],
|
],
|
||||||
order: [['title', 'ASC']],
|
order: [['title', 'ASC']],
|
||||||
@@ -321,7 +321,7 @@ class AiQueryController {
|
|||||||
{ model: EntryRating, as: 'entryRating', attributes: { exclude: ['id', 'entry_id'] } },
|
{ model: EntryRating, as: 'entryRating', attributes: { exclude: ['id', 'entry_id'] } },
|
||||||
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } },
|
{ model: Genre, as: 'genres', attributes: ['id', 'name'], through: { attributes: [] } },
|
||||||
{ model: Network, as: 'networks', 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,
|
model: Credit, as: 'credits', limit: 20,
|
||||||
include: [{ model: People, as: 'person', attributes: ['id', 'name', 'profile_path', 'known_for_department'] }]
|
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']
|
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) => {
|
getAllCollections = asyncWrapper(async (req, res) => {
|
||||||
const collections = await Collection.findAll({
|
const collections = await Collection.findAll({
|
||||||
attributes: ['id', 'name', 'description', 'is_user_collection', 'poster_path', 'backdrop_path'],
|
attributes: ['id', 'name', 'description', 'isUserCollection', 'posterPath', 'backdropPath'],
|
||||||
include: [{
|
include: [{
|
||||||
model: Entry,
|
model: Entry,
|
||||||
as: 'entries',
|
as: 'entries',
|
||||||
@@ -398,9 +398,9 @@ class AiQueryController {
|
|||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
description: c.description,
|
description: c.description,
|
||||||
is_user_collection: c.is_user_collection,
|
is_user_collection: c.isUserCollection,
|
||||||
poster_path: c.poster_path,
|
poster_path: c.posterPath,
|
||||||
backdrop_path: c.backdrop_path,
|
backdrop_path: c.backdropPath,
|
||||||
entry_count: c.entries.length
|
entry_count: c.entries.length
|
||||||
})));
|
})));
|
||||||
});
|
});
|
||||||
@@ -416,7 +416,7 @@ class AiQueryController {
|
|||||||
as: 'entries',
|
as: 'entries',
|
||||||
through: { attributes: ['order'] },
|
through: { attributes: ['order'] },
|
||||||
include: [
|
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: [] } }
|
{ model: Genre, as: 'genres', attributes: ['name'], through: { attributes: [] } }
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
@@ -443,7 +443,7 @@ class AiQueryController {
|
|||||||
include: [{ model: EpisodeSeen, as: 'episodeSeens', attributes: ['id'], required: false }]
|
include: [{ model: EpisodeSeen, as: 'episodeSeens', attributes: ['id'], required: false }]
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{ model: EntryRating, as: 'entryRating', attributes: ['userRating'] }
|
{ model: EntryRating, as: 'entryRating', attributes: ['user_rating'] }
|
||||||
],
|
],
|
||||||
distinct: true
|
distinct: true
|
||||||
});
|
});
|
||||||
@@ -461,7 +461,7 @@ class AiQueryController {
|
|||||||
title: s.title,
|
title: s.title,
|
||||||
poster_path: s.poster_path,
|
poster_path: s.poster_path,
|
||||||
banner_path: s.banner_path,
|
banner_path: s.banner_path,
|
||||||
user_rating: s.entryRating?.userRating || null,
|
user_rating: s.entryRating?.user_rating || null,
|
||||||
total_episodes: totalEpisodes,
|
total_episodes: totalEpisodes,
|
||||||
seen_episodes: seenEpisodes,
|
seen_episodes: seenEpisodes,
|
||||||
progress_pct: totalEpisodes > 0 ? Math.round((seenEpisodes / totalEpisodes) * 100) : 0,
|
progress_pct: totalEpisodes > 0 ? Math.round((seenEpisodes / totalEpisodes) * 100) : 0,
|
||||||
|
|||||||
Reference in new issue
Block a user