diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index aa7c1a4..9863a17 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -125,9 +125,11 @@ public class MangaController(PgsqlContext context) : Controller Manga? m = context.Manga.Find(id); if (m is null) return NotFound("Manga could not be found"); - if (m.LatestChapterAvailable is null) + List chapters = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToList(); + Chapter? max = chapters.Max(); + if (max is null) return NotFound("Chapter could not be found"); - return Ok(m.LatestChapterAvailable); + return Ok(max); } /// diff --git a/API/Schema/Manga.cs b/API/Schema/Manga.cs index 5a4cfb7..9cab486 100644 --- a/API/Schema/Manga.cs +++ b/API/Schema/Manga.cs @@ -22,8 +22,6 @@ public class Manga( string? originalLanguage, MangaReleaseStatus releaseStatus, float ignoreChapterBefore, - Chapter? latestChapterDownloaded, - Chapter? latestChapterAvailable, MangaConnector mangaConnector, ICollection authors, ICollection tags, @@ -46,12 +44,6 @@ public class Manga( public string FolderName { get; private set; } = BuildFolderName(name); public float IgnoreChapterBefore { get; internal set; } = ignoreChapterBefore; - [ForeignKey("LatestChapterDownloadedId")] - public Chapter? LatestChapterDownloaded { get; private set; } = latestChapterDownloaded; - - [ForeignKey("LatestChapterAvailableId")] - public Chapter? LatestChapterAvailable { get; private set; } = latestChapterAvailable; - [ForeignKey("MangaConnectorId")] public MangaConnector MangaConnector { get; private set; } = mangaConnector; @@ -68,7 +60,7 @@ public class Manga( uint year, string? originalLanguage, MangaReleaseStatus releaseStatus, float ignoreChapterBefore) : this(connectorId, name, description, websiteUrl, coverUrl, coverFileNameInCache, year, originalLanguage, releaseStatus, - ignoreChapterBefore, null, null, null, null, null, null, null) + ignoreChapterBefore, null, null, null, null, null) { } @@ -91,7 +83,6 @@ public class Manga( this.Links = other.Links; this.Tags = other.Tags; this.AltTitles = other.AltTitles; - this.LatestChapterAvailable = other.LatestChapterAvailable; this.ReleaseStatus = other.ReleaseStatus; } diff --git a/API/Schema/MangaConnectors/AsuraToon.cs b/API/Schema/MangaConnectors/AsuraToon.cs index 2e1682c..5bdda6f 100644 --- a/API/Schema/MangaConnectors/AsuraToon.cs +++ b/API/Schema/MangaConnectors/AsuraToon.cs @@ -110,7 +110,7 @@ public class AsuraToon : MangaConnector uint year = uint.Parse(firstChapterNode?.InnerText.Split(' ')[^1] ?? "2000"); Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/Bato.cs b/API/Schema/MangaConnectors/Bato.cs index f5122dc..45d3f3c 100644 --- a/API/Schema/MangaConnectors/Bato.cs +++ b/API/Schema/MangaConnectors/Bato.cs @@ -112,7 +112,7 @@ public class Bato : MangaConnector } Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/MangaDex.cs b/API/Schema/MangaConnectors/MangaDex.cs index cc0ecee..833108b 100644 --- a/API/Schema/MangaConnectors/MangaDex.cs +++ b/API/Schema/MangaConnectors/MangaDex.cs @@ -175,7 +175,7 @@ public class MangaDex : MangaConnector List authors = authorNames.Select(a => new Author(a)).ToList(); Manga pub = new (publicationId, sortName, description, $"https://mangadex.org/title/{publicationId}", coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/MangaHere.cs b/API/Schema/MangaConnectors/MangaHere.cs index 7320d2c..e6551e7 100644 --- a/API/Schema/MangaConnectors/MangaHere.cs +++ b/API/Schema/MangaConnectors/MangaHere.cs @@ -100,7 +100,7 @@ public class MangaHere : MangaConnector string description = descriptionNode.InnerText; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, 0, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/MangaKatana.cs b/API/Schema/MangaConnectors/MangaKatana.cs index a4b38ad..b28bd3e 100644 --- a/API/Schema/MangaConnectors/MangaKatana.cs +++ b/API/Schema/MangaConnectors/MangaKatana.cs @@ -140,7 +140,7 @@ public class MangaKatana : MangaConnector List altTitles = altTitlesDict.Select(x => new MangaAltTitle(x.Key, x.Value)).ToList(); Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/MangaLife.cs b/API/Schema/MangaConnectors/MangaLife.cs index ccbc6c2..24a97a3 100644 --- a/API/Schema/MangaConnectors/MangaLife.cs +++ b/API/Schema/MangaConnectors/MangaLife.cs @@ -119,7 +119,7 @@ public class MangaLife : MangaConnector string description = descriptionNode.InnerText; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/Manganato.cs b/API/Schema/MangaConnectors/Manganato.cs index 22db030..4c72da3 100644 --- a/API/Schema/MangaConnectors/Manganato.cs +++ b/API/Schema/MangaConnectors/Manganato.cs @@ -135,7 +135,7 @@ public class Manganato : MangaConnector CultureInfo.InvariantCulture).Year; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/Mangasee.cs b/API/Schema/MangaConnectors/Mangasee.cs index 2e29920..86e04cf 100644 --- a/API/Schema/MangaConnectors/Mangasee.cs +++ b/API/Schema/MangaConnectors/Mangasee.cs @@ -149,7 +149,7 @@ public class Mangasee : MangaConnector string description = descriptionNode.InnerText; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/Mangaworld.cs b/API/Schema/MangaConnectors/Mangaworld.cs index 3f33b4d..cf483e9 100644 --- a/API/Schema/MangaConnectors/Mangaworld.cs +++ b/API/Schema/MangaConnectors/Mangaworld.cs @@ -116,7 +116,7 @@ public class Mangaworld : MangaConnector uint year = uint.Parse(yearString); Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/ManhuaPlus.cs b/API/Schema/MangaConnectors/ManhuaPlus.cs index be1fcb6..dc6e2d0 100644 --- a/API/Schema/MangaConnectors/ManhuaPlus.cs +++ b/API/Schema/MangaConnectors/ManhuaPlus.cs @@ -121,7 +121,7 @@ public class ManhuaPlus : MangaConnector string description = descriptionNode.InnerText; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/MangaConnectors/WeebCentral.cs b/API/Schema/MangaConnectors/WeebCentral.cs index 74c4a5c..53700cb 100644 --- a/API/Schema/MangaConnectors/WeebCentral.cs +++ b/API/Schema/MangaConnectors/WeebCentral.cs @@ -113,7 +113,7 @@ public class Weebcentral : MangaConnector var originalLanguage = ""; Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year, - originalLanguage, releaseStatus, -1, null, null, + originalLanguage, releaseStatus, -1, this, authors, mangaTags, diff --git a/API/Schema/PgsqlContext.cs b/API/Schema/PgsqlContext.cs index 85bd163..9697152 100644 --- a/API/Schema/PgsqlContext.cs +++ b/API/Schema/PgsqlContext.cs @@ -90,7 +90,6 @@ public class PgsqlContext(DbContextOptions options) : DbContext(op modelBuilder.Entity() .Navigation(m => m.AltTitles) .AutoInclude(); - modelBuilder.Entity() .HasOne(c => c.ParentManga) .WithMany();