refactor: make PALDRA match PDCA style exactly - remove redundant instanceConfig parameter and convert to pure singleton
- Remove instanceConfig parameter from all retriever methods (getTags, getQueue, getHistory) - Retriever instances now use this.url, this.apiKey, this.id instead of passed parameter - Convert ArrRetrieverRegistry from class with convenience functions to pure singleton object - Export singleton instance directly instead of class + convenience functions - Update poller.js and historyFetcher.js to call methods on singleton directly - All 261 tests pass with zero behavior changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2026 Gordon Bolton. MIT License.
|
||||
const cache = require('./cache');
|
||||
const { getSonarrInstances, getRadarrInstances } = require('./config');
|
||||
const { initializeRetrievers, getRetrieversByType } = require('./arrRetrievers');
|
||||
const arrRetrieverRegistry = require('./arrRetrievers');
|
||||
|
||||
// Cache TTL for recent-history data: 5 minutes.
|
||||
// History changes slowly compared to active downloads.
|
||||
@@ -27,17 +27,17 @@ async function fetchSonarrHistory(since) {
|
||||
if (cached) return cached;
|
||||
|
||||
// Ensure retrievers are initialized
|
||||
await initializeRetrievers();
|
||||
await arrRetrieverRegistry.initialize();
|
||||
|
||||
const instances = getSonarrInstances();
|
||||
const sonarrRetrievers = getRetrieversByType('sonarr');
|
||||
const sonarrRetrievers = arrRetrieverRegistry.getRetrieversByType('sonarr');
|
||||
|
||||
const results = await Promise.all(sonarrRetrievers.map(async (retriever) => {
|
||||
const inst = instances.find(i => i.id === retriever.getInstanceId());
|
||||
if (!inst) return [];
|
||||
|
||||
try {
|
||||
const response = await retriever.getHistory(retriever, {
|
||||
const response = await retriever.getHistory({
|
||||
pageSize: 100,
|
||||
sortKey: 'date',
|
||||
sortDir: 'descending',
|
||||
@@ -76,17 +76,17 @@ async function fetchRadarrHistory(since) {
|
||||
if (cached) return cached;
|
||||
|
||||
// Ensure retrievers are initialized
|
||||
await initializeRetrievers();
|
||||
await arrRetrieverRegistry.initialize();
|
||||
|
||||
const instances = getRadarrInstances();
|
||||
const radarrRetrievers = getRetrieversByType('radarr');
|
||||
const radarrRetrievers = arrRetrieverRegistry.getRetrieversByType('radarr');
|
||||
|
||||
const results = await Promise.all(radarrRetrievers.map(async (retriever) => {
|
||||
const inst = instances.find(i => i.id === retriever.getInstanceId());
|
||||
if (!inst) return [];
|
||||
|
||||
try {
|
||||
const response = await retriever.getHistory(retriever, {
|
||||
const response = await retriever.getHistory({
|
||||
pageSize: 100,
|
||||
sortKey: 'date',
|
||||
sortDir: 'descending',
|
||||
|
||||
Reference in New Issue
Block a user