mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-04 09:54:16 +02:00
28 lines
842 B
C#
28 lines
842 B
C#
using API.Schema.MangaContext;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace API.Workers;
|
|
|
|
public class UpdateChaptersDownloadedWorker(Manga manga, IServiceScope scope, IEnumerable<BaseWorker>? dependsOn = null)
|
|
: BaseWorkerWithContext<MangaContext>(scope, dependsOn), IPeriodic<UpdateChaptersDownloadedWorker>
|
|
{
|
|
public DateTime LastExecution { get; set; } = DateTime.UtcNow;
|
|
public TimeSpan Interval { get; set; } = TimeSpan.FromMinutes(60);
|
|
protected override BaseWorker[] DoWorkInternal()
|
|
{
|
|
foreach (Chapter mangaChapter in manga.Chapters)
|
|
{
|
|
mangaChapter.Downloaded = mangaChapter.CheckDownloaded();
|
|
}
|
|
|
|
try
|
|
{
|
|
DbContext.SaveChanges();
|
|
}
|
|
catch (DbUpdateException e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
return [];
|
|
}
|
|
} |