fix: limit history pagination to prevent 40s response times
The full pagination fix (ddad80a,e772001) caused history retrieval to fetch up to 50 pages sequentially, taking 10-40 seconds instead of ~200ms. Changes: - Add maxPages parameter to getHistory() with default of 1 page - Update poller to fetch 50 records (up from 10) in a single API call - historyFetcher retains 100 records per page for UI display This provides 5x more history for matching than before while keeping the fast single-request performance. Refs: develop-merge pagination performance issue
This commit is contained in:
@@ -71,7 +71,8 @@ class PollingRadarrRetriever extends ArrRetriever {
|
||||
/**
|
||||
* Get history from Radarr instance
|
||||
* @param {Object} options - Optional parameters for history fetch
|
||||
* @param {number} [options.pageSize=10] - Number of records to fetch
|
||||
* @param {number} [options.pageSize=100] - Number of records to fetch per page
|
||||
* @param {number} [options.maxPages=1] - Maximum pages to fetch (for pagination control)
|
||||
* @param {string} [options.sortKey] - Field to sort by
|
||||
* @param {string} [options.sortDir] - Sort direction ('ascending' or 'descending')
|
||||
* @param {boolean} [options.includeMovie=true] - Include movie data
|
||||
@@ -81,6 +82,7 @@ class PollingRadarrRetriever extends ArrRetriever {
|
||||
async getHistory(options = {}) {
|
||||
const {
|
||||
pageSize = 100,
|
||||
maxPages = 1,
|
||||
sortKey,
|
||||
sortDir,
|
||||
includeMovie = true,
|
||||
@@ -119,7 +121,7 @@ class PollingRadarrRetriever extends ArrRetriever {
|
||||
page++;
|
||||
} while (
|
||||
(responseData.records || (Array.isArray(responseData) ? responseData : [])).length === pageSize &&
|
||||
page <= 50
|
||||
page <= maxPages
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -71,7 +71,8 @@ class PollingSonarrRetriever extends ArrRetriever {
|
||||
/**
|
||||
* Get history from Sonarr instance
|
||||
* @param {Object} options - Optional parameters for history fetch
|
||||
* @param {number} [options.pageSize=10] - Number of records to fetch
|
||||
* @param {number} [options.pageSize=100] - Number of records to fetch per page
|
||||
* @param {number} [options.maxPages=1] - Maximum pages to fetch (for pagination control)
|
||||
* @param {string} [options.sortKey] - Field to sort by
|
||||
* @param {string} [options.sortDir] - Sort direction ('ascending' or 'descending')
|
||||
* @param {boolean} [options.includeSeries=true] - Include series data
|
||||
@@ -82,6 +83,7 @@ class PollingSonarrRetriever extends ArrRetriever {
|
||||
async getHistory(options = {}) {
|
||||
const {
|
||||
pageSize = 100,
|
||||
maxPages = 1,
|
||||
sortKey,
|
||||
sortDir,
|
||||
includeSeries = true,
|
||||
@@ -122,7 +124,7 @@ class PollingSonarrRetriever extends ArrRetriever {
|
||||
page++;
|
||||
} while (
|
||||
(responseData.records || (Array.isArray(responseData) ? responseData : [])).length === pageSize &&
|
||||
page <= 50
|
||||
page <= maxPages
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -118,7 +118,7 @@ async function pollAllServices() {
|
||||
return queuesByType.sonarr || [];
|
||||
}) : timed('Sonarr Queue', async () => []),
|
||||
shouldPollSonarr ? timed('Sonarr History', async () => {
|
||||
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 10 });
|
||||
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 50 });
|
||||
return historyByType.sonarr || [];
|
||||
}) : timed('Sonarr History', async () => []),
|
||||
shouldPollRadarr ? timed('Radarr Queue', async () => {
|
||||
@@ -126,7 +126,7 @@ async function pollAllServices() {
|
||||
return queuesByType.radarr || [];
|
||||
}) : timed('Radarr Queue', async () => []),
|
||||
shouldPollRadarr ? timed('Radarr History', async () => {
|
||||
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 10 });
|
||||
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 50 });
|
||||
return historyByType.radarr || [];
|
||||
}) : timed('Radarr History', async () => []),
|
||||
shouldPollRadarr ? timed('Radarr Tags', async () => {
|
||||
|
||||
Reference in New Issue
Block a user