refactor: make PALDRA match PDCA style exactly - remove redundant instanceConfig parameter and convert to pure singleton
Build and Push Docker Image / build (push) Successful in 20s
CI / Security audit (push) Successful in 1m18s
CI / Tests & coverage (push) Successful in 1m14s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 54s

- 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:
2026-05-19 14:51:22 +01:00
parent 627329df2f
commit 6e199925aa
6 changed files with 66 additions and 95 deletions
+7 -7
View File
@@ -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',