From f30208559666008dbd7c970a11ca27c83f47e3f7 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 16 Oct 2025 23:56:04 +0200 Subject: [PATCH] Fix filter endtime --- API/Controllers/ActionsController.cs | 8 ++++---- API/Schema/ActionsContext/ActionsContext.cs | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/API/Controllers/ActionsController.cs b/API/Controllers/ActionsController.cs index a84f565..7054ed1 100644 --- a/API/Controllers/ActionsController.cs +++ b/API/Controllers/ActionsController.cs @@ -37,9 +37,9 @@ public class ActionsController(ActionsContext context) : Controller [ProducesResponseType(Status500InternalServerError)] public async Task>, InternalServerError>> GetActionsInterval([FromBody]Filter filter) { - if (await context.Filter(filter.MangaId, filter.ChapterId) + if (await context.FilterActions(filter.MangaId, filter.ChapterId) .Where(a => filter.Start == null || a.PerformedAt >= filter.Start.Value.ToUniversalTime()) - .Where(a => filter.End == null || a.PerformedAt >= filter.End.Value.ToUniversalTime()) + .Where(a => filter.End == null || a.PerformedAt <= filter.End.Value.ToUniversalTime()) .Where(a => filter.Action == null || a.Action == filter.Action) .ToListAsync(HttpContext.RequestAborted) is not { } actions) return TypedResults.InternalServerError(); @@ -73,7 +73,7 @@ public class ActionsController(ActionsContext context) : Controller [ProducesResponseType(Status500InternalServerError)] public async Task>, InternalServerError>> GetActionsRelatedToManga(string MangaId) { - if(await context.FilterManga(MangaId).ToListAsync(HttpContext.RequestAborted) is not { } actions) + if(await context.FilterActionsManga(MangaId).ToListAsync(HttpContext.RequestAborted) is not { } actions) return TypedResults.InternalServerError(); return TypedResults.Ok(actions.Select(a => new ActionRecord(a))); @@ -89,7 +89,7 @@ public class ActionsController(ActionsContext context) : Controller [ProducesResponseType(Status500InternalServerError)] public async Task>, InternalServerError>> GetActionsRelatedToChapter(string ChapterId) { - if(await context.FilterChapter(ChapterId).ToListAsync(HttpContext.RequestAborted) is not { } actions) + if(await context.FilterActionsChapter(ChapterId).ToListAsync(HttpContext.RequestAborted) is not { } actions) return TypedResults.InternalServerError(); return TypedResults.Ok(actions.Select(a => new ActionRecord(a))); diff --git a/API/Schema/ActionsContext/ActionsContext.cs b/API/Schema/ActionsContext/ActionsContext.cs index 7ea6b88..55b8d53 100644 --- a/API/Schema/ActionsContext/ActionsContext.cs +++ b/API/Schema/ActionsContext/ActionsContext.cs @@ -32,23 +32,23 @@ public class ActionsContext(DbContextOptions options) : TrangaBa modelBuilder.Entity().Property(a => a.MangaId).HasColumnName("MangaId"); } - public IQueryable FilterManga(string MangaId) => this.Actions + public IQueryable FilterActionsManga(string MangaId) => this.Actions .FromSqlInterpolated($"""SELECT * FROM public."Actions" WHERE "MangaId" = {MangaId}"""); - public IQueryable FilterChapter(string ChapterId) => this.Actions + public IQueryable FilterActionsChapter(string ChapterId) => this.Actions .FromSqlInterpolated($"""SELECT * FROM public."Actions" WHERE "ChapterId" = {ChapterId}"""); - public IQueryable FilterMangaAndChapter(string MangaId, string ChapterId) => this.Actions + public IQueryable FilterActionsMangaAndChapter(string MangaId, string ChapterId) => this.Actions .FromSqlInterpolated($"""SELECT * FROM public."Actions" WHERE "MangaId" = {MangaId} AND "ChapterId" = {ChapterId}"""); - public IQueryable Filter(string? MangaId, string? ChapterId) + public IQueryable FilterActions(string? MangaId, string? ChapterId) { if (MangaId is { } mangaId && ChapterId is { } chapterId) - return FilterMangaAndChapter(mangaId, chapterId); + return FilterActionsMangaAndChapter(mangaId, chapterId); if (MangaId is { } mangaId2) - return FilterManga(mangaId2); + return FilterActionsManga(mangaId2); if (ChapterId is { } chapterId2) - return FilterChapter(chapterId2); + return FilterActionsChapter(chapterId2); return this.Actions.AsQueryable(); } } \ No newline at end of file