From 71d9cc47bafcebcda086c5bc96fe8f87b2c2f600 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 14 Oct 2025 23:50:07 +0200 Subject: [PATCH] Speedup withtag --- API/Controllers/MangaController.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index db24392..bd9c174 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -326,22 +326,20 @@ public class MangaController(MangaContext context) : Controller [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound, "text/plain")] [ProducesResponseType(Status500InternalServerError)] - public async Task>, NotFound, InternalServerError>> GetMangasWithTag (string Tag) + public async Task>, NotFound, InternalServerError>> GetMangasWithTag (string Tag) { - if (await context.MangaIncludeAll() + if (await context.Mangas + .Include(m => m.MangaConnectorIds) + .Include(m => m.MangaTags) .Where(m => m.MangaTags.Any(t => t.Tag == Tag)) .OrderBy(m => m.Name) .ToListAsync(HttpContext.RequestAborted) is not { } result) return TypedResults.InternalServerError(); - + return TypedResults.Ok(result.Select(m => { IEnumerable ids = m.MangaConnectorIds.Select(id => new MangaConnectorId(id.Key, id.MangaConnectorName, id.ObjId, id.WebsiteUrl, id.UseForDownload)); - IEnumerable authors = m.Authors.Select(a => new Author(a.Key, a.AuthorName)); - IEnumerable tags = m.MangaTags.Select(t => t.Tag); - IEnumerable links = m.Links.Select(l => new Link(l.Key, l.LinkProvider, l.LinkUrl)); - IEnumerable altTitles = m.AltTitles.Select(a => new AltTitle(a.Language, a.Title)); - return new Manga(m.Key, m.Name, m.Description, m.ReleaseStatus, ids, m.IgnoreChaptersBefore, m.Year, m.OriginalLanguage, m.ChapterIds, authors, tags, links, altTitles, m.LibraryId); + return new MinimalManga(m.Key, m.Name, m.Description, m.ReleaseStatus, ids); }).ToList()); }