From 42e3357e15ddbe4fc8458e89e14379975346028d Mon Sep 17 00:00:00 2001 From: Ted Wollman <25165500+TheTedder@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:55:53 -0400 Subject: [PATCH] Add includeDeleted param to ListLeaderboards. --- LeaderboardBackend/Services/ILeaderboardService.cs | 2 +- LeaderboardBackend/Services/Impl/LeaderboardService.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/LeaderboardBackend/Services/ILeaderboardService.cs b/LeaderboardBackend/Services/ILeaderboardService.cs index 2c3371d3..789a48fb 100644 --- a/LeaderboardBackend/Services/ILeaderboardService.cs +++ b/LeaderboardBackend/Services/ILeaderboardService.cs @@ -9,7 +9,7 @@ public interface ILeaderboardService { Task GetLeaderboard(long id); Task GetLeaderboardBySlug(string slug); - Task> ListLeaderboards(); + Task> ListLeaderboards(bool includeDeleted); Task CreateLeaderboard(CreateLeaderboardRequest request); Task RestoreLeaderboard(long id); Task DeleteLeaderboard(long id); diff --git a/LeaderboardBackend/Services/Impl/LeaderboardService.cs b/LeaderboardBackend/Services/Impl/LeaderboardService.cs index 35bdc1c8..d34489ee 100644 --- a/LeaderboardBackend/Services/Impl/LeaderboardService.cs +++ b/LeaderboardBackend/Services/Impl/LeaderboardService.cs @@ -18,9 +18,11 @@ await applicationContext.Leaderboards .FirstOrDefaultAsync(b => b.Slug == slug && b.DeletedAt == null); // FIXME: Paginate these - public async Task> ListLeaderboards() => - await applicationContext.Leaderboards - .Where(lb => lb.DeletedAt == null).ToListAsync(); + public async Task> ListLeaderboards(bool includeDeleted) + { + IQueryable lbs = applicationContext.Leaderboards; + return await (includeDeleted ? lbs : lbs.Where(lb => lb.DeletedAt == null)).ToListAsync(); + } public async Task CreateLeaderboard(CreateLeaderboardRequest request) {