refactor: make PALDRA match PDCA style exactly - remove redundant instanceConfig parameter and convert to pure singleton
All checks were successful
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

View File

@@ -2,7 +2,7 @@
const axios = require('axios');
const cache = require('./cache');
const { initializeClients, getAllDownloads, getDownloadsByClientType } = require('./downloadClients');
const { initializeRetrievers, getTagsByType, getQueuesByType, getHistoryByType } = require('./arrRetrievers');
const arrRetrieverRegistry = require('./arrRetrievers');
const {
getSonarrInstances,
getRadarrInstances
@@ -41,7 +41,7 @@ async function pollAllServices() {
try {
// Ensure download clients and *arr retrievers are initialized
await initializeClients();
await initializeRetrievers();
await arrRetrieverRegistry.initialize();
const sonarrInstances = getSonarrInstances();
const radarrInstances = getRadarrInstances();
@@ -53,27 +53,27 @@ async function pollAllServices() {
return downloadsByType;
}),
timed('Sonarr Tags', async () => {
const tagsByType = await getTagsByType();
const tagsByType = await arrRetrieverRegistry.getTagsByType();
return tagsByType.sonarr || [];
}),
timed('Sonarr Queue', async () => {
const queuesByType = await getQueuesByType();
const queuesByType = await arrRetrieverRegistry.getQueuesByType();
return queuesByType.sonarr || [];
}),
timed('Sonarr History', async () => {
const historyByType = await getHistoryByType({ pageSize: 10 });
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 10 });
return historyByType.sonarr || [];
}),
timed('Radarr Queue', async () => {
const queuesByType = await getQueuesByType();
const queuesByType = await arrRetrieverRegistry.getQueuesByType();
return queuesByType.radarr || [];
}),
timed('Radarr History', async () => {
const historyByType = await getHistoryByType({ pageSize: 10 });
const historyByType = await arrRetrieverRegistry.getHistoryByType({ pageSize: 10 });
return historyByType.radarr || [];
}),
timed('Radarr Tags', async () => {
const tagsByType = await getTagsByType();
const tagsByType = await arrRetrieverRegistry.getTagsByType();
return tagsByType.radarr || [];
}),
]);