mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 03:48:19 +02:00
30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using API.Schema.MangaContext;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace API.Workers;
|
|
|
|
/// <summary>
|
|
/// Creates Jobs to update available Chapters for all Manga that are marked for Download
|
|
/// </summary>
|
|
public class CheckForNewChaptersWorker(TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
|
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
|
{
|
|
public DateTime LastExecution { get; set; } = DateTime.UnixEpoch;
|
|
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromMinutes(60);
|
|
|
|
protected override async Task<BaseWorker[]> DoWorkInternal()
|
|
{
|
|
Log.Debug("Checking for new chapters...");
|
|
List<MangaConnectorId<Manga>> connectorIdsManga = await DbContext.MangaConnectorToManga
|
|
.Include(id => id.Obj)
|
|
.Where(id => id.UseForDownload)
|
|
.ToListAsync(CancellationToken);
|
|
Log.Debug($"Creating {connectorIdsManga.Count} update jobs...");
|
|
|
|
List<BaseWorker> newWorkers = connectorIdsManga.Select(id => new RetrieveMangaChaptersFromMangaconnectorWorker(id, Tranga.Settings.DownloadLanguage))
|
|
.ToList<BaseWorker>();
|
|
|
|
return newWorkers.ToArray();
|
|
}
|
|
|
|
} |