fix: full pagination + non-silent errors in PollingRadarrRetriever
Licence Check / Licence compatibility and copyright header verification (push) Successful in 51s
CI / Tests & coverage (push) Failing after 1m8s
CI / Security audit (push) Successful in 1m15s
CI / Tests & coverage (pull_request) Failing after 4s
Licence Check / Licence compatibility and copyright header verification (pull_request) Successful in 1m6s
CI / Security audit (pull_request) Successful in 1m35s

This commit is contained in:
2026-05-20 20:42:18 +01:00
parent 1f10414498
commit ddad80a666
+59 -21
View File
@@ -37,17 +37,35 @@ class PollingRadarrRetriever extends ArrRetriever {
* @returns {Promise<Object>} Queue object with records array * @returns {Promise<Object>} Queue object with records array
*/ */
async getQueue() { async getQueue() {
try { const instanceName = this.name;
// Fetch with large page size to get all items (Radarr has pagination) let page = 1;
const response = await axios.get(`${this.url}/api/v3/queue`, { let allRecords = [];
headers: { 'X-Api-Key': this.apiKey }, let responseData = null;
params: { includeMovie: true, pageSize: 1000 }
}); do {
return response.data; try {
} catch (error) { const response = await axios.get(`${this.url}/api/v3/queue`, {
logToFile(`[PollingRadarrRetriever] ${this.id} queue error: ${error.message}`); headers: { 'X-Api-Key': this.apiKey },
return { records: [] }; params: { includeMovie: true, page, pageSize: 1000 }
} });
responseData = response.data;
} catch (error) {
console.error(`Radarr queue fetch failed for instance ${instanceName}:`, error.response?.data || error.message);
throw error;
}
const records = responseData.records || (Array.isArray(responseData) ? responseData : []);
allRecords = allRecords.concat(records);
page++;
} while (
(responseData.records || (Array.isArray(responseData) ? responseData : [])).length === 1000 &&
page <= 50
);
return {
...responseData,
records: allRecords
};
} }
/** /**
@@ -69,8 +87,14 @@ class PollingRadarrRetriever extends ArrRetriever {
startDate startDate
} = options; } = options;
try { const instanceName = this.name;
let page = 1;
let allRecords = [];
let responseData = null;
do {
const params = { const params = {
page,
pageSize, pageSize,
includeMovie includeMovie
}; };
@@ -79,15 +103,29 @@ class PollingRadarrRetriever extends ArrRetriever {
if (sortDir) params.sortDir = sortDir; if (sortDir) params.sortDir = sortDir;
if (startDate) params.startDate = startDate; if (startDate) params.startDate = startDate;
const response = await axios.get(`${this.url}/api/v3/history`, { try {
headers: { 'X-Api-Key': this.apiKey }, const response = await axios.get(`${this.url}/api/v3/history`, {
params headers: { 'X-Api-Key': this.apiKey },
}); params
return response.data; });
} catch (error) { responseData = response.data;
logToFile(`[PollingRadarrRetriever] ${this.id} history error: ${error.message}`); } catch (error) {
return { records: [] }; console.error(`Radarr history fetch failed for instance ${instanceName}:`, error.response?.data || error.message);
} throw error;
}
const records = responseData.records || (Array.isArray(responseData) ? responseData : []);
allRecords = allRecords.concat(records);
page++;
} while (
(responseData.records || (Array.isArray(responseData) ? responseData : [])).length === pageSize &&
page <= 50
);
return {
...responseData,
records: allRecords
};
} }
} }