Revert "perf: split into fast poll + slow-cached library fetches"
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
This reverts commit 78a8737f29.
This commit is contained in:
@@ -140,17 +140,13 @@ router.get('/user-downloads', async (req, res) => {
|
||||
// Read all data from cache
|
||||
const sabQueueData = cache.get('poll:sab-queue') || { slots: [] };
|
||||
const sabHistoryData = cache.get('poll:sab-history') || { slots: [] };
|
||||
const sonarrTagsResults = cache.get('poll:sonarr-tags') || [];
|
||||
const sonarrQueueData = cache.get('poll:sonarr-queue') || { records: [] };
|
||||
const sonarrHistoryData = cache.get('poll:sonarr-history') || { records: [] };
|
||||
const radarrQueueData = cache.get('poll:radarr-queue') || { records: [] };
|
||||
const radarrHistoryData = cache.get('poll:radarr-history') || { records: [] };
|
||||
const qbittorrentTorrents = cache.get('poll:qbittorrent') || [];
|
||||
|
||||
// Slow-cached data (series/movie libraries + tags, refreshed every 5 min)
|
||||
const sonarrSeriesData = cache.get('poll:sonarr-series') || [];
|
||||
const radarrMoviesData = cache.get('poll:radarr-movies') || [];
|
||||
const sonarrTagsResults = cache.get('poll:sonarr-tags') || [];
|
||||
const radarrTagsData = cache.get('poll:radarr-tags') || [];
|
||||
const qbittorrentTorrents = cache.get('poll:qbittorrent') || [];
|
||||
|
||||
// Wrap in the structure the rest of the code expects
|
||||
const sabnzbdQueue = { data: { queue: sabQueueData } };
|
||||
@@ -161,9 +157,23 @@ router.get('/user-downloads', async (req, res) => {
|
||||
const radarrHistory = { data: radarrHistoryData };
|
||||
const radarrTags = { data: radarrTagsData };
|
||||
|
||||
// Build series/movie maps from the slow-cached full library
|
||||
const seriesMap = new Map(sonarrSeriesData.map(s => [s.id, s]));
|
||||
const moviesMap = new Map(radarrMoviesData.map(m => [m.id, m]));
|
||||
// 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);
|
||||
}
|
||||
for (const r of sonarrHistory.data.records) {
|
||||
if (r.series && r.seriesId && !seriesMap.has(r.seriesId)) seriesMap.set(r.seriesId, r.series);
|
||||
}
|
||||
const moviesMap = new Map();
|
||||
for (const r of radarrQueue.data.records) {
|
||||
if (r.movie && r.movieId) moviesMap.set(r.movieId, r.movie);
|
||||
}
|
||||
for (const r of radarrHistory.data.records) {
|
||||
if (r.movie && r.movieId && !moviesMap.has(r.movieId)) moviesMap.set(r.movieId, r.movie);
|
||||
}
|
||||
|
||||
// Create tag maps (id -> label)
|
||||
const sonarrTagMap = new Map(sonarrTagsResults.flatMap(t => t.data || []).map(t => [t.id, t.label]));
|
||||
|
||||
Reference in New Issue
Block a user