Manga latest downloaded and available via SQL Queries

This commit is contained in:
Glax 2024-12-18 16:42:59 +01:00
parent 5494f2b754
commit 55c0e2c4e7
14 changed files with 16 additions and 24 deletions

View File

@ -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<Chapter> 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);
}
/// <summary>

View File

@ -22,8 +22,6 @@ public class Manga(
string? originalLanguage,
MangaReleaseStatus releaseStatus,
float ignoreChapterBefore,
Chapter? latestChapterDownloaded,
Chapter? latestChapterAvailable,
MangaConnector mangaConnector,
ICollection<Author> authors,
ICollection<MangaTag> 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;
}

View File

@ -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,

View File

@ -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,

View File

@ -175,7 +175,7 @@ public class MangaDex : MangaConnector
List<Author> 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,

View File

@ -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,

View File

@ -140,7 +140,7 @@ public class MangaKatana : MangaConnector
List<MangaAltTitle> 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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -90,7 +90,6 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
modelBuilder.Entity<Manga>()
.Navigation(m => m.AltTitles)
.AutoInclude();
modelBuilder.Entity<Chapter>()
.HasOne<Manga>(c => c.ParentManga)
.WithMany();