Actions initial commit
Some checks failed
Docker Image CI / build (push) Has been cancelled

This commit is contained in:
2025-10-16 02:52:04 +02:00
parent 13fb917c5d
commit 53276e858b
36 changed files with 1013 additions and 169 deletions

View File

@@ -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();
}