mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-17 19:00:45 +02:00
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using API.Schema.MangaContext;
|
||||
using API.Workers.MangaDownloadWorkers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -10,15 +11,22 @@ namespace API.Workers.PeriodicWorkers;
|
||||
/// <param name="interval"></param>
|
||||
/// <param name="dependsOn"></param>
|
||||
public class UpdateCoversWorker(TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
||||
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
||||
: BaseWorkerWithContexts(dependsOn), IPeriodic
|
||||
{
|
||||
|
||||
public DateTime LastExecution { get; set; } = DateTime.UnixEpoch;
|
||||
public TimeSpan Interval { get; set; } = interval ?? TimeSpan.FromHours(6);
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
private MangaContext MangaContext = null!;
|
||||
|
||||
protected override void SetContexts(IServiceScope serviceScope)
|
||||
{
|
||||
MangaContext = GetContext<MangaContext>(serviceScope);
|
||||
}
|
||||
|
||||
protected override async Task<BaseWorker[]> DoWorkInternal()
|
||||
{
|
||||
List<MangaConnectorId<Manga>> manga = await DbContext.MangaConnectorToManga.Where(mcId => mcId.UseForDownload).ToListAsync(CancellationToken);
|
||||
List<MangaConnectorId<Manga>> manga = await MangaContext.MangaConnectorToManga.Where(mcId => mcId.UseForDownload).ToListAsync(CancellationToken);
|
||||
List<BaseWorker> newWorkers = manga.Select(m => new DownloadCoverFromMangaconnectorWorker(m)).ToList<BaseWorker>();
|
||||
return newWorkers.ToArray();
|
||||
}
|
||||
|
Reference in New Issue
Block a user