mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-22 06:03:01 +02:00
Use LazyLoading
This commit is contained in:
parent
110dd36166
commit
3a3306240f
@ -19,6 +19,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.5" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
|
@ -122,12 +122,9 @@ using (IServiceScope scope = app.Services.CreateScope())
|
|||||||
context.LocalLibraries.Add(new LocalLibrary(TrangaSettings.downloadLocation, "Default Library"));
|
context.LocalLibraries.Add(new LocalLibrary(TrangaSettings.downloadLocation, "Default Library"));
|
||||||
|
|
||||||
context.Jobs.AddRange(context.Jobs.Where(j => j.JobType == JobType.DownloadAvailableChaptersJob)
|
context.Jobs.AddRange(context.Jobs.Where(j => j.JobType == JobType.DownloadAvailableChaptersJob)
|
||||||
.AsEnumerable()
|
.Include(downloadAvailableChaptersJob => ((DownloadAvailableChaptersJob)downloadAvailableChaptersJob).Manga)
|
||||||
.Select(dacj =>
|
.ToList()
|
||||||
{
|
.Select(dacj => new UpdateChaptersDownloadedJob(((DownloadAvailableChaptersJob)dacj).Manga, 0)));
|
||||||
DownloadAvailableChaptersJob? j = dacj as DownloadAvailableChaptersJob;
|
|
||||||
return new UpdateChaptersDownloadedJob(j!.Manga, 0);
|
|
||||||
}));
|
|
||||||
context.Jobs.RemoveRange(context.Jobs.Where(j => j.state == JobState.Completed && j.RecurrenceMs < 1));
|
context.Jobs.RemoveRange(context.Jobs.Where(j => j.state == JobState.Completed && j.RecurrenceMs < 1));
|
||||||
foreach (Job job in context.Jobs.Where(j => j.state == JobState.Running))
|
foreach (Job job in context.Jobs.Where(j => j.state == JobState.Running))
|
||||||
{
|
{
|
||||||
@ -153,7 +150,7 @@ using (IServiceScope scope = app.Services.CreateScope())
|
|||||||
TrangaSettings.Load();
|
TrangaSettings.Load();
|
||||||
Tranga.StartLogger();
|
Tranga.StartLogger();
|
||||||
Tranga.JobStarterThread.Start(app.Services);
|
Tranga.JobStarterThread.Start(app.Services);
|
||||||
Tranga.NotificationSenderThread.Start(app.Services);
|
//Tranga.NotificationSenderThread.Start(app.Services); //TODO RE-ENABLE
|
||||||
|
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<DownloadAvailableChaptersJob>()
|
modelBuilder.Entity<DownloadAvailableChaptersJob>()
|
||||||
.Navigation(j => j.Manga)
|
.Navigation(j => j.Manga)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<DownloadMangaCoverJob>()
|
modelBuilder.Entity<DownloadMangaCoverJob>()
|
||||||
.HasOne<Manga>(j => j.Manga)
|
.HasOne<Manga>(j => j.Manga)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -59,7 +59,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<DownloadMangaCoverJob>()
|
modelBuilder.Entity<DownloadMangaCoverJob>()
|
||||||
.Navigation(j => j.Manga)
|
.Navigation(j => j.Manga)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<DownloadSingleChapterJob>()
|
modelBuilder.Entity<DownloadSingleChapterJob>()
|
||||||
.HasOne<Chapter>(j => j.Chapter)
|
.HasOne<Chapter>(j => j.Chapter)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -68,7 +68,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<DownloadSingleChapterJob>()
|
modelBuilder.Entity<DownloadSingleChapterJob>()
|
||||||
.Navigation(j => j.Chapter)
|
.Navigation(j => j.Chapter)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<MoveMangaLibraryJob>()
|
modelBuilder.Entity<MoveMangaLibraryJob>()
|
||||||
.HasOne<Manga>(j => j.Manga)
|
.HasOne<Manga>(j => j.Manga)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -77,7 +77,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<MoveMangaLibraryJob>()
|
modelBuilder.Entity<MoveMangaLibraryJob>()
|
||||||
.Navigation(j => j.Manga)
|
.Navigation(j => j.Manga)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<MoveMangaLibraryJob>()
|
modelBuilder.Entity<MoveMangaLibraryJob>()
|
||||||
.HasOne<LocalLibrary>(j => j.ToLibrary)
|
.HasOne<LocalLibrary>(j => j.ToLibrary)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -86,7 +86,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<MoveMangaLibraryJob>()
|
modelBuilder.Entity<MoveMangaLibraryJob>()
|
||||||
.Navigation(j => j.ToLibrary)
|
.Navigation(j => j.ToLibrary)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<RetrieveChaptersJob>()
|
modelBuilder.Entity<RetrieveChaptersJob>()
|
||||||
.HasOne<Manga>(j => j.Manga)
|
.HasOne<Manga>(j => j.Manga)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -95,7 +95,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<RetrieveChaptersJob>()
|
modelBuilder.Entity<RetrieveChaptersJob>()
|
||||||
.Navigation(j => j.Manga)
|
.Navigation(j => j.Manga)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
modelBuilder.Entity<UpdateChaptersDownloadedJob>()
|
modelBuilder.Entity<UpdateChaptersDownloadedJob>()
|
||||||
.HasOne<Manga>(j => j.Manga)
|
.HasOne<Manga>(j => j.Manga)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -104,14 +104,13 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
modelBuilder.Entity<UpdateChaptersDownloadedJob>()
|
modelBuilder.Entity<UpdateChaptersDownloadedJob>()
|
||||||
.Navigation(j => j.Manga)
|
.Navigation(j => j.Manga)
|
||||||
.AutoInclude();
|
.EnableLazyLoading();
|
||||||
|
|
||||||
//Job has possible ParentJob
|
//Job has possible ParentJob
|
||||||
modelBuilder.Entity<Job>()
|
modelBuilder.Entity<Job>()
|
||||||
.HasMany<Job>()
|
.HasOne<Job>(childJob => childJob.ParentJob)
|
||||||
.WithOne(childJob => childJob.ParentJob)
|
.WithMany()
|
||||||
.HasForeignKey(childjob => childjob.ParentJobId)
|
.HasForeignKey(childjob => childjob.ParentJobId)
|
||||||
.IsRequired(false)
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
//Job might be dependent on other Jobs
|
//Job might be dependent on other Jobs
|
||||||
modelBuilder.Entity<Job>()
|
modelBuilder.Entity<Job>()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -7,7 +8,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class DownloadAvailableChaptersJob : Job
|
public class DownloadAvailableChaptersJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string MangaId { get; init; }
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
||||||
[JsonIgnore] public Manga Manga { get; init; } = null!;
|
|
||||||
|
private Manga _manga = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Manga Manga
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _manga);
|
||||||
|
init => _manga = value;
|
||||||
|
}
|
||||||
|
|
||||||
public DownloadAvailableChaptersJob(Manga manga, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
public DownloadAvailableChaptersJob(Manga manga, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadAvailableChaptersJob)), JobType.DownloadAvailableChaptersJob, recurrenceMs, parentJob, dependsOnJobs)
|
: base(TokenGen.CreateToken(typeof(DownloadAvailableChaptersJob)), JobType.DownloadAvailableChaptersJob, recurrenceMs, parentJob, dependsOnJobs)
|
||||||
@ -19,8 +28,8 @@ public class DownloadAvailableChaptersJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal DownloadAvailableChaptersJob(string mangaId, ulong recurrenceMs, string? parentJobId)
|
internal DownloadAvailableChaptersJob(ILazyLoader lazyLoader, string mangaId, ulong recurrenceMs, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadAvailableChaptersJob)), JobType.DownloadAvailableChaptersJob, recurrenceMs, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(DownloadAvailableChaptersJob)), JobType.DownloadAvailableChaptersJob, recurrenceMs, parentJobId)
|
||||||
{
|
{
|
||||||
this.MangaId = mangaId;
|
this.MangaId = mangaId;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -8,7 +9,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class DownloadMangaCoverJob : Job
|
public class DownloadMangaCoverJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string MangaId { get; init; }
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
||||||
[JsonIgnore] public Manga Manga { get; init; } = null!;
|
|
||||||
|
private Manga _manga = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Manga Manga
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _manga);
|
||||||
|
init => _manga = value;
|
||||||
|
}
|
||||||
|
|
||||||
public DownloadMangaCoverJob(Manga manga, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
public DownloadMangaCoverJob(Manga manga, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadMangaCoverJob)), JobType.DownloadMangaCoverJob, 0, parentJob, dependsOnJobs)
|
: base(TokenGen.CreateToken(typeof(DownloadMangaCoverJob)), JobType.DownloadMangaCoverJob, 0, parentJob, dependsOnJobs)
|
||||||
@ -20,8 +29,8 @@ public class DownloadMangaCoverJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal DownloadMangaCoverJob(string mangaId, string? parentJobId)
|
internal DownloadMangaCoverJob(ILazyLoader lazyLoader, string mangaId, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadMangaCoverJob)), JobType.DownloadMangaCoverJob, 0, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(DownloadMangaCoverJob)), JobType.DownloadMangaCoverJob, 0, parentJobId)
|
||||||
{
|
{
|
||||||
this.MangaId = mangaId;
|
this.MangaId = mangaId;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
|
|||||||
using API.MangaDownloadClients;
|
using API.MangaDownloadClients;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
@ -17,7 +18,14 @@ public class DownloadSingleChapterJob : Job
|
|||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string ChapterId { get; init; }
|
[StringLength(64)] [Required] public string ChapterId { get; init; }
|
||||||
|
|
||||||
[JsonIgnore] public Chapter Chapter { get; init; } = null!;
|
private Chapter _chapter = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Chapter Chapter
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _chapter);
|
||||||
|
init => _chapter = value;
|
||||||
|
}
|
||||||
|
|
||||||
public DownloadSingleChapterJob(Chapter chapter, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
public DownloadSingleChapterJob(Chapter chapter, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadSingleChapterJob)), JobType.DownloadSingleChapterJob, 0, parentJob, dependsOnJobs)
|
: base(TokenGen.CreateToken(typeof(DownloadSingleChapterJob)), JobType.DownloadSingleChapterJob, 0, parentJob, dependsOnJobs)
|
||||||
@ -29,8 +37,8 @@ public class DownloadSingleChapterJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal DownloadSingleChapterJob(string chapterId, string? parentJobId)
|
internal DownloadSingleChapterJob(ILazyLoader lazyLoader, string chapterId, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(DownloadSingleChapterJob)), JobType.DownloadSingleChapterJob, 0, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(DownloadSingleChapterJob)), JobType.DownloadSingleChapterJob, 0, parentJobId)
|
||||||
{
|
{
|
||||||
this.ChapterId = chapterId;
|
this.ChapterId = chapterId;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -32,6 +33,7 @@ public abstract class Job
|
|||||||
[JsonIgnore] [NotMapped] internal bool DependenciesFulfilled => DependsOnJobs.All(j => j.IsCompleted);
|
[JsonIgnore] [NotMapped] internal bool DependenciesFulfilled => DependsOnJobs.All(j => j.IsCompleted);
|
||||||
|
|
||||||
[NotMapped] [JsonIgnore] protected ILog Log { get; init; }
|
[NotMapped] [JsonIgnore] protected ILog Log { get; init; }
|
||||||
|
[NotMapped] [JsonIgnore] protected ILazyLoader LazyLoader { get; init; }
|
||||||
|
|
||||||
protected Job(string jobId, JobType jobType, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
protected Job(string jobId, JobType jobType, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
{
|
{
|
||||||
@ -48,8 +50,9 @@ public abstract class Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected internal Job(string jobId, JobType jobType, ulong recurrenceMs, string? parentJobId)
|
protected internal Job(ILazyLoader lazyLoader, string jobId, JobType jobType, ulong recurrenceMs, string? parentJobId)
|
||||||
{
|
{
|
||||||
|
this.LazyLoader = lazyLoader;
|
||||||
this.JobId = jobId;
|
this.JobId = jobId;
|
||||||
this.JobType = jobType;
|
this.JobType = jobType;
|
||||||
this.RecurrenceMs = recurrenceMs;
|
this.RecurrenceMs = recurrenceMs;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ public class MoveFileOrFolderJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal MoveFileOrFolderJob(string jobId, string fromLocation, string toLocation, string? parentJobId)
|
internal MoveFileOrFolderJob(ILazyLoader lazyLoader, string jobId, string fromLocation, string toLocation, string? parentJobId)
|
||||||
: base(jobId, JobType.MoveFileOrFolderJob, 0, parentJobId)
|
: base(lazyLoader, jobId, JobType.MoveFileOrFolderJob, 0, parentJobId)
|
||||||
{
|
{
|
||||||
this.FromLocation = fromLocation;
|
this.FromLocation = fromLocation;
|
||||||
this.ToLocation = toLocation;
|
this.ToLocation = toLocation;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -8,7 +9,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class MoveMangaLibraryJob : Job
|
public class MoveMangaLibraryJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string MangaId { get; init; }
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
||||||
[JsonIgnore] public Manga Manga { get; init; } = null!;
|
|
||||||
|
private Manga _manga = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Manga Manga
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _manga);
|
||||||
|
init => _manga = value;
|
||||||
|
}
|
||||||
[StringLength(64)] [Required] public string ToLibraryId { get; init; }
|
[StringLength(64)] [Required] public string ToLibraryId { get; init; }
|
||||||
public LocalLibrary ToLibrary { get; init; } = null!;
|
public LocalLibrary ToLibrary { get; init; } = null!;
|
||||||
|
|
||||||
@ -24,8 +33,8 @@ public class MoveMangaLibraryJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal MoveMangaLibraryJob(string mangaId, string toLibraryId, string? parentJobId)
|
internal MoveMangaLibraryJob(ILazyLoader lazyLoader, string mangaId, string toLibraryId, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(MoveMangaLibraryJob)), JobType.MoveMangaLibraryJob, 0, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(MoveMangaLibraryJob)), JobType.MoveMangaLibraryJob, 0, parentJobId)
|
||||||
{
|
{
|
||||||
this.MangaId = mangaId;
|
this.MangaId = mangaId;
|
||||||
this.ToLibraryId = toLibraryId;
|
this.ToLibraryId = toLibraryId;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -8,7 +9,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class RetrieveChaptersJob : Job
|
public class RetrieveChaptersJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string MangaId { get; init; }
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
||||||
[JsonIgnore] public Manga Manga { get; init; } = null!;
|
|
||||||
|
private Manga _manga = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Manga Manga
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _manga);
|
||||||
|
init => _manga = value;
|
||||||
|
}
|
||||||
[StringLength(8)] [Required] public string Language { get; private set; }
|
[StringLength(8)] [Required] public string Language { get; private set; }
|
||||||
|
|
||||||
public RetrieveChaptersJob(Manga manga, string language, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
public RetrieveChaptersJob(Manga manga, string language, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
@ -22,8 +31,8 @@ public class RetrieveChaptersJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal RetrieveChaptersJob(string mangaId, string language, ulong recurrenceMs, string? parentJobId)
|
internal RetrieveChaptersJob(ILazyLoader lazyLoader, string mangaId, string language, ulong recurrenceMs, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(RetrieveChaptersJob)), JobType.RetrieveChaptersJob, recurrenceMs, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(RetrieveChaptersJob)), JobType.RetrieveChaptersJob, recurrenceMs, parentJobId)
|
||||||
{
|
{
|
||||||
this.MangaId = mangaId;
|
this.MangaId = mangaId;
|
||||||
this.Language = language;
|
this.Language = language;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -8,7 +8,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class UpdateChaptersDownloadedJob : Job
|
public class UpdateChaptersDownloadedJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string MangaId { get; init; }
|
[StringLength(64)] [Required] public string MangaId { get; init; }
|
||||||
[JsonIgnore] public Manga Manga { get; init; } = null!;
|
|
||||||
|
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)
|
public UpdateChaptersDownloadedJob(Manga manga, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
: base(TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJob, dependsOnJobs)
|
: base(TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJob, dependsOnJobs)
|
||||||
@ -20,8 +28,8 @@ public class UpdateChaptersDownloadedJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal UpdateChaptersDownloadedJob(string mangaId, ulong recurrenceMs, string? parentJobId)
|
internal UpdateChaptersDownloadedJob(ILazyLoader lazyLoader, string mangaId, ulong recurrenceMs, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(UpdateChaptersDownloadedJob)), JobType.UpdateChaptersDownloadedJob, recurrenceMs, parentJobId)
|
||||||
{
|
{
|
||||||
this.MangaId = mangaId;
|
this.MangaId = mangaId;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.Contexts;
|
using API.Schema.Contexts;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
@ -8,7 +9,15 @@ namespace API.Schema.Jobs;
|
|||||||
public class UpdateSingleChapterDownloadedJob : Job
|
public class UpdateSingleChapterDownloadedJob : Job
|
||||||
{
|
{
|
||||||
[StringLength(64)] [Required] public string ChapterId { get; init; }
|
[StringLength(64)] [Required] public string ChapterId { get; init; }
|
||||||
[JsonIgnore] public Chapter Chapter { get; init; } = null!;
|
|
||||||
|
private Chapter _chapter = null!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Chapter Chapter
|
||||||
|
{
|
||||||
|
get => LazyLoader.Load(this, ref _chapter);
|
||||||
|
init => _chapter = value;
|
||||||
|
}
|
||||||
|
|
||||||
public UpdateSingleChapterDownloadedJob(Chapter chapter, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
public UpdateSingleChapterDownloadedJob(Chapter chapter, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||||
: base(TokenGen.CreateToken(typeof(UpdateSingleChapterDownloadedJob)), JobType.UpdateSingleChapterDownloadedJob, 0, parentJob, dependsOnJobs)
|
: base(TokenGen.CreateToken(typeof(UpdateSingleChapterDownloadedJob)), JobType.UpdateSingleChapterDownloadedJob, 0, parentJob, dependsOnJobs)
|
||||||
@ -20,8 +29,8 @@ public class UpdateSingleChapterDownloadedJob : Job
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// EF ONLY!!!
|
/// EF ONLY!!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal UpdateSingleChapterDownloadedJob(string chapterId, string? parentJobId)
|
internal UpdateSingleChapterDownloadedJob(ILazyLoader lazyLoader, string chapterId, string? parentJobId)
|
||||||
: base(TokenGen.CreateToken(typeof(UpdateSingleChapterDownloadedJob)), JobType.UpdateSingleChapterDownloadedJob, 0, parentJobId)
|
: base(lazyLoader, TokenGen.CreateToken(typeof(UpdateSingleChapterDownloadedJob)), JobType.UpdateSingleChapterDownloadedJob, 0, parentJobId)
|
||||||
{
|
{
|
||||||
this.ChapterId = chapterId;
|
this.ChapterId = chapterId;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user