mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Fix merging of Manga
Fix ComickIo empty lists
This commit is contained in:
@@ -39,6 +39,7 @@ public class Chapter : Identifiable, IComparable<Chapter>
|
||||
this.Title = title;
|
||||
this.FileName = GetArchiveFilePath();
|
||||
this.Downloaded = false;
|
||||
this.MangaConnectorIds = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -61,6 +61,7 @@ public class Manga : Identifiable
|
||||
this.Year = year;
|
||||
this.OriginalLanguage = originalLanguage;
|
||||
this.Chapters = [];
|
||||
this.MangaConnectorIds = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -8,7 +8,7 @@ namespace API.Schema.MangaContext;
|
||||
[PrimaryKey("Key")]
|
||||
public class MangaConnectorId<T> : Identifiable where T : Identifiable
|
||||
{
|
||||
[StringLength(64)] [Required] public string ObjId { get; private set; }
|
||||
[StringLength(64)] [Required] public string ObjId { get; internal set; }
|
||||
[JsonIgnore] public T Obj = null!;
|
||||
|
||||
[StringLength(32)] [Required] public string MangaConnectorName { get; private set; }
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using API.MangaConnectors;
|
||||
using API.Schema.MangaContext.MetadataFetchers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
|
||||
namespace API.Schema.MangaContext;
|
||||
|
||||
@@ -102,4 +103,23 @@ public class MangaContext(DbContextOptions<MangaContext> options) : TrangaBaseCo
|
||||
.WithMany()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
|
||||
public Manga? FindMangaLike(Manga other)
|
||||
{
|
||||
if (MangaIncludeAll().FirstOrDefault(m => m.Key == other.Key) is { } f)
|
||||
return f;
|
||||
|
||||
return MangaIncludeAll()
|
||||
.FirstOrDefault(m => m.Links.Any(l => l.Key == other.Key) ||
|
||||
m.AltTitles.Any(t => other.AltTitles.Select(ot => ot.Title)
|
||||
.Any(s => s.Equals(t.Title))));
|
||||
}
|
||||
|
||||
public IIncludableQueryable<Manga, ICollection<MangaConnectorId<Manga>>> MangaIncludeAll() => Mangas.Include(m => m.Library)
|
||||
.Include(m => m.Authors)
|
||||
.Include(m => m.MangaTags)
|
||||
.Include(m => m.Links)
|
||||
.Include(m => m.AltTitles)
|
||||
.Include(m => m.Chapters)
|
||||
.Include(m => m.MangaConnectorIds);
|
||||
}
|
Reference in New Issue
Block a user