Refresh airing TV series when the calendar is opened
- POST /entries/sync-series starts a background refresh of airing TV series (not Ended/Canceled, auto sync on) not refreshed in the last 24h; manual refreshes reset that clock. GET kept as an alias, plus GET /entries/sync-series/status for progress - Reuses the rate-limited stale refresh job with a series-only scope; only one refresh job runs at a time - Calendar starts the sync on visit, shows progress, and reloads episodes and the library when it finishes - Remove the old SyncSeriesData, whose date check no longer worked
This commit is contained in:
1 parent
a88423163e
commit
ac0030d611
8 files changed
+119
-214
No files matched your search
@@ -10,6 +10,10 @@ const {
|
||||
mapEntryRatings,
|
||||
} = require("../mappers/entryMapper");
|
||||
const asyncWrapper = require("../utils/asyncWrapper");
|
||||
const maintenanceService = require("../services/maintenanceService");
|
||||
|
||||
// TV series are refreshed at most once per this many hours by the calendar sync
|
||||
const SERIES_SYNC_HOURS = 24;
|
||||
|
||||
const _collectionManager = collectionManager;
|
||||
const _entryManager = entryManager;
|
||||
@@ -97,11 +101,19 @@ class EntryController {
|
||||
res.status(200).json({ message: `Entry with ID ${id} deleted.` });
|
||||
});
|
||||
|
||||
// * GET - SYNC ALL ENTIRES DATA
|
||||
syncSeries = asyncWrapper(async (req, res, next) => {
|
||||
const entries = await _entryManager.SyncSeriesData();
|
||||
// * POST - SYNC TV SERIES (calendar)
|
||||
// Starts a background refresh of airing TV series not refreshed in the last
|
||||
// 24h (manual refreshes reset that clock). Returns the job status at once.
|
||||
syncSeries = asyncWrapper(async (req, res) => {
|
||||
const job = await maintenanceService.startStaleRefresh(SERIES_SYNC_HOURS, {
|
||||
seriesOnly: true,
|
||||
});
|
||||
res.status(job.alreadyRunning ? 200 : 202).json(job);
|
||||
});
|
||||
|
||||
res.status(201).json(entries);
|
||||
// * GET - SYNC TV SERIES STATUS
|
||||
syncSeriesStatus = asyncWrapper(async (req, res) => {
|
||||
res.status(200).json(maintenanceService.getStaleRefreshStatus());
|
||||
});
|
||||
|
||||
// * GET - Get seasons of an entry
|
||||
|
||||
Reference in new issue
Block a user