fix(watchlist-sync): handle empty watchlists on PostgreSQL (#2718)
This commit is contained in:
@@ -97,7 +97,12 @@ export const startJobs = (): void => {
|
|||||||
logger.info('Starting scheduled job: Plex Watchlist Sync', {
|
logger.info('Starting scheduled job: Plex Watchlist Sync', {
|
||||||
label: 'Jobs',
|
label: 'Jobs',
|
||||||
});
|
});
|
||||||
watchlistSync.syncWatchlist();
|
watchlistSync.syncWatchlist().catch((e) => {
|
||||||
|
logger.error('Failed to sync watchlists', {
|
||||||
|
label: 'Plex Watchlist Sync',
|
||||||
|
errorMessage: e.message,
|
||||||
|
});
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (
|
||||||
|
|||||||
@@ -76,13 +76,18 @@ class WatchlistSync {
|
|||||||
const watchlistTmdbIds = response.items.map((i) => i.tmdbId);
|
const watchlistTmdbIds = response.items.map((i) => i.tmdbId);
|
||||||
|
|
||||||
const requestRepository = getRepository(MediaRequest);
|
const requestRepository = getRepository(MediaRequest);
|
||||||
const existingAutoRequests = await requestRepository
|
const existingAutoRequests: MediaRequest[] =
|
||||||
|
watchlistTmdbIds.length > 0
|
||||||
|
? await requestRepository
|
||||||
.createQueryBuilder('request')
|
.createQueryBuilder('request')
|
||||||
.leftJoinAndSelect('request.media', 'media')
|
.leftJoinAndSelect('request.media', 'media')
|
||||||
.where('request.requestedBy = :userId', { userId: user.id })
|
.where('request.requestedBy = :userId', { userId: user.id })
|
||||||
.andWhere('request.isAutoRequest = true')
|
.andWhere('request.isAutoRequest = true')
|
||||||
.andWhere('media.tmdbId IN (:...tmdbIds)', { tmdbIds: watchlistTmdbIds })
|
.andWhere('media.tmdbId IN (:...tmdbIds)', {
|
||||||
.getMany();
|
tmdbIds: watchlistTmdbIds,
|
||||||
|
})
|
||||||
|
.getMany()
|
||||||
|
: [];
|
||||||
|
|
||||||
const autoRequestedTmdbIds = new Set(
|
const autoRequestedTmdbIds = new Set(
|
||||||
existingAutoRequests
|
existingAutoRequests
|
||||||
|
|||||||
Reference in New Issue
Block a user