mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-21 13:43:01 +02:00
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using API.Schema.Contexts;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace API.Schema.Jobs;
|
|
|
|
public class UpdateChaptersDownloadedJob : Job
|
|
{
|
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
|
|
|
private Manga _manga = null!;
|
|
|
|
[JsonIgnore]
|
|
public Manga Manga
|
|
{
|
|
get => LazyLoader.Load(this, ref _manga);
|
|
init => _manga = value;
|
|
}
|
|
|
|
public UpdateChaptersDownloadedJob(Manga manga, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
|
: base(TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJob, dependsOnJobs)
|
|
{
|
|
this.MangaId = manga.MangaId;
|
|
this.Manga = manga;
|
|
}
|
|
|
|
/// <summary>
|
|
/// EF ONLY!!!
|
|
/// </summary>
|
|
internal UpdateChaptersDownloadedJob(ILazyLoader lazyLoader, string mangaId, ulong recurrenceMs, string? parentJobId)
|
|
: base(lazyLoader, TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJobId)
|
|
{
|
|
this.MangaId = mangaId;
|
|
}
|
|
|
|
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
|
{
|
|
return Manga.Chapters.Select(c => new UpdateSingleChapterDownloadedJob(c, this));
|
|
}
|
|
} |