mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-04 09:54:16 +02:00
StartNewChapterDownloadsWorker.cs
This commit is contained in:
22
API/Workers/PeriodicWorkers/CheckForNewChaptersWorker.cs
Normal file
22
API/Workers/PeriodicWorkers/CheckForNewChaptersWorker.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using API.Schema.MangaContext;
|
||||
|
||||
namespace API.Workers;
|
||||
|
||||
public class CheckForNewChaptersWorker(TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
||||
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
||||
{
|
||||
public DateTime LastExecution { get; set; } = DateTime.UtcNow;
|
||||
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromMinutes(60);
|
||||
|
||||
protected override BaseWorker[] DoWorkInternal()
|
||||
{
|
||||
IQueryable<MangaConnectorId<Manga>> connectorIdsManga = DbContext.MangaConnectorToManga.Where(id => id.UseForDownload);
|
||||
|
||||
List<BaseWorker> newWorkers = new();
|
||||
foreach (MangaConnectorId<Manga> mangaConnectorId in connectorIdsManga)
|
||||
newWorkers.Add(new RetrieveMangaChaptersFromMangaconnectorWorker(mangaConnectorId, Tranga.Settings.DownloadLanguage));
|
||||
|
||||
return newWorkers.ToArray();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user