Skip to content

Commit 55c0e2c

Browse files
committed
Manga latest downloaded and available via SQL Queries
1 parent 5494f2b commit 55c0e2c

14 files changed

+16
-24
lines changed

API/Controllers/MangaController.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ public IActionResult GetLatestChapter(string id)
125125
Manga? m = context.Manga.Find(id);
126126
if (m is null)
127127
return NotFound("Manga could not be found");
128-
if (m.LatestChapterAvailable is null)
128+
List<Chapter> chapters = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToList();
129+
Chapter? max = chapters.Max();
130+
if (max is null)
129131
return NotFound("Chapter could not be found");
130-
return Ok(m.LatestChapterAvailable);
132+
return Ok(max);
131133
}
132134

133135
/// <summary>

API/Schema/Manga.cs

+1-10
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class Manga(
2222
string? originalLanguage,
2323
MangaReleaseStatus releaseStatus,
2424
float ignoreChapterBefore,
25-
Chapter? latestChapterDownloaded,
26-
Chapter? latestChapterAvailable,
2725
MangaConnector mangaConnector,
2826
ICollection<Author> authors,
2927
ICollection<MangaTag> tags,
@@ -46,12 +44,6 @@ public class Manga(
4644
public string FolderName { get; private set; } = BuildFolderName(name);
4745
public float IgnoreChapterBefore { get; internal set; } = ignoreChapterBefore;
4846

49-
[ForeignKey("LatestChapterDownloadedId")]
50-
public Chapter? LatestChapterDownloaded { get; private set; } = latestChapterDownloaded;
51-
52-
[ForeignKey("LatestChapterAvailableId")]
53-
public Chapter? LatestChapterAvailable { get; private set; } = latestChapterAvailable;
54-
5547
[ForeignKey("MangaConnectorId")]
5648
public MangaConnector MangaConnector { get; private set; } = mangaConnector;
5749

@@ -68,7 +60,7 @@ public Manga(string connectorId, string name, string description, string website
6860
uint year, string? originalLanguage, MangaReleaseStatus releaseStatus, float ignoreChapterBefore)
6961
: this(connectorId, name, description, websiteUrl, coverUrl, coverFileNameInCache, year, originalLanguage,
7062
releaseStatus,
71-
ignoreChapterBefore, null, null, null, null, null, null, null)
63+
ignoreChapterBefore, null, null, null, null, null)
7264
{
7365

7466
}
@@ -91,7 +83,6 @@ internal void UpdateWithInfo(Manga other)
9183
this.Links = other.Links;
9284
this.Tags = other.Tags;
9385
this.AltTitles = other.AltTitles;
94-
this.LatestChapterAvailable = other.LatestChapterAvailable;
9586
this.ReleaseStatus = other.ReleaseStatus;
9687
}
9788

API/Schema/MangaConnectors/AsuraToon.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
110110
uint year = uint.Parse(firstChapterNode?.InnerText.Split(' ')[^1] ?? "2000");
111111

112112
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
113-
originalLanguage, releaseStatus, -1, null, null,
113+
originalLanguage, releaseStatus, -1,
114114
this,
115115
authors,
116116
mangaTags,

API/Schema/MangaConnectors/Bato.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
112112
}
113113

114114
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
115-
originalLanguage, releaseStatus, -1, null, null,
115+
originalLanguage, releaseStatus, -1,
116116
this,
117117
authors,
118118
mangaTags,

API/Schema/MangaConnectors/MangaDex.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
175175
List<Author> authors = authorNames.Select(a => new Author(a)).ToList();
176176

177177
Manga pub = new (publicationId, sortName, description, $"https://mangadex.org/title/{publicationId}", coverUrl, null, year,
178-
originalLanguage, releaseStatus, -1, null, null,
178+
originalLanguage, releaseStatus, -1,
179179
this,
180180
authors,
181181
mangaTags,

API/Schema/MangaConnectors/MangaHere.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
100100
string description = descriptionNode.InnerText;
101101

102102
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, 0,
103-
originalLanguage, releaseStatus, -1, null, null,
103+
originalLanguage, releaseStatus, -1,
104104
this,
105105
authors,
106106
mangaTags,

API/Schema/MangaConnectors/MangaKatana.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
140140
List<MangaAltTitle> altTitles = altTitlesDict.Select(x => new MangaAltTitle(x.Key, x.Value)).ToList();
141141

142142
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
143-
originalLanguage, releaseStatus, -1, null, null,
143+
originalLanguage, releaseStatus, -1,
144144
this,
145145
authors,
146146
mangaTags,

API/Schema/MangaConnectors/MangaLife.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
119119
string description = descriptionNode.InnerText;
120120

121121
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
122-
originalLanguage, releaseStatus, -1, null, null,
122+
originalLanguage, releaseStatus, -1,
123123
this,
124124
authors,
125125
mangaTags,

API/Schema/MangaConnectors/Manganato.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
135135
CultureInfo.InvariantCulture).Year;
136136

137137
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
138-
originalLanguage, releaseStatus, -1, null, null,
138+
originalLanguage, releaseStatus, -1,
139139
this,
140140
authors,
141141
mangaTags,

API/Schema/MangaConnectors/Mangasee.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
149149
string description = descriptionNode.InnerText;
150150

151151
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
152-
originalLanguage, releaseStatus, -1, null, null,
152+
originalLanguage, releaseStatus, -1,
153153
this,
154154
authors,
155155
mangaTags,

API/Schema/MangaConnectors/Mangaworld.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
116116
uint year = uint.Parse(yearString);
117117

118118
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
119-
originalLanguage, releaseStatus, -1, null, null,
119+
originalLanguage, releaseStatus, -1,
120120
this,
121121
authors,
122122
mangaTags,

API/Schema/MangaConnectors/ManhuaPlus.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
121121
string description = descriptionNode.InnerText;
122122

123123
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
124-
originalLanguage, releaseStatus, -1, null, null,
124+
originalLanguage, releaseStatus, -1,
125125
this,
126126
authors,
127127
mangaTags,

API/Schema/MangaConnectors/WeebCentral.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public override (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaA
113113
var originalLanguage = "";
114114

115115
Manga manga = new (publicationId, sortName, description, websiteUrl, coverUrl, null, year,
116-
originalLanguage, releaseStatus, -1, null, null,
116+
originalLanguage, releaseStatus, -1,
117117
this,
118118
authors,
119119
mangaTags,

API/Schema/PgsqlContext.cs

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
9090
modelBuilder.Entity<Manga>()
9191
.Navigation(m => m.AltTitles)
9292
.AutoInclude();
93-
9493
modelBuilder.Entity<Chapter>()
9594
.HasOne<Manga>(c => c.ParentManga)
9695
.WithMany();

0 commit comments

Comments
 (0)