perf: drop includeSeries/includeMovie from history fetches

Sonarr/Radarr history with include* params forces expensive DB
joins (~2s each). History records still have seriesId/movieId
for matching; the series/movie objects come from the queue-built
maps instead.

Trade-off: completed downloads only show if the series/movie
is also currently in the queue. Active downloads unaffected.
This commit is contained in:
2026-05-16 00:16:31 +01:00
parent 1327c8e466
commit 31ff973eff
2 changed files with 7 additions and 20 deletions

View File

@@ -157,8 +157,9 @@ router.get('/user-downloads', async (req, res) => {
const radarrHistory = { data: radarrHistoryData };
const radarrTags = { data: radarrTagsData };
// Build series/movie maps from embedded objects in queue + history records
// (no need to fetch the full library — queue/history include the full object)
// Build series/movie maps from embedded objects in queue records
// (history is fetched without includeSeries/includeMovie for speed;
// history matches fall back to the queue-built map via seriesId/movieId)
const seriesMap = new Map();
for (const r of sonarrQueue.data.records) {
if (r.series && r.seriesId) seriesMap.set(r.seriesId, r.series);