perf: drop includeSeries/includeMovie from history fetches
All checks were successful
Build and Push Docker Image / build (push) Successful in 23s

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 980e20247c
commit d5542abd27
2 changed files with 7 additions and 20 deletions

View File

@@ -74,7 +74,7 @@ async function pollAllServices() {
timed('Sonarr History', () => Promise.all(sonarrInstances.map(inst =>
axios.get(`${inst.url}/api/v3/history`, {
headers: { 'X-Api-Key': inst.apiKey },
params: { pageSize: 10, includeSeries: true }
params: { pageSize: 10 }
}).then(res => ({ instance: inst.id, data: res.data })).catch(err => {
console.error(`[Poller] Sonarr ${inst.id} history error:`, err.message);
return { instance: inst.id, data: { records: [] } };
@@ -92,7 +92,7 @@ async function pollAllServices() {
timed('Radarr History', () => Promise.all(radarrInstances.map(inst =>
axios.get(`${inst.url}/api/v3/history`, {
headers: { 'X-Api-Key': inst.apiKey },
params: { pageSize: 10, includeMovie: true }
params: { pageSize: 10 }
}).then(res => ({ instance: inst.id, data: res.data })).catch(err => {
console.error(`[Poller] Radarr ${inst.id} history error:`, err.message);
return { instance: inst.id, data: { records: [] } };
@@ -160,14 +160,7 @@ async function pollAllServices() {
})
}, cacheTTL);
cache.set('poll:sonarr-history', {
records: sonarrHistories.flatMap(h => {
const inst = sonarrInstances.find(i => i.id === h.instance);
const url = inst ? inst.url : null;
return (h.data.records || []).map(r => {
if (r.series) r.series._instanceUrl = url;
return r;
});
})
records: sonarrHistories.flatMap(h => h.data.records || [])
}, cacheTTL);
// Radarr
@@ -182,14 +175,7 @@ async function pollAllServices() {
})
}, cacheTTL);
cache.set('poll:radarr-history', {
records: radarrHistories.flatMap(h => {
const inst = radarrInstances.find(i => i.id === h.instance);
const url = inst ? inst.url : null;
return (h.data.records || []).map(r => {
if (r.movie) r.movie._instanceUrl = url;
return r;
});
})
records: radarrHistories.flatMap(h => h.data.records || [])
}, cacheTTL);
cache.set('poll:radarr-tags', radarrTagsResults.flatMap(t => t.data || []), cacheTTL);