Skip to content

Commit

Permalink
Add includeDeleted param to ListLeaderboards.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTedder committed Oct 28, 2024
1 parent 0ad319f commit 42e3357
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LeaderboardBackend/Services/ILeaderboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface ILeaderboardService
{
Task<Leaderboard?> GetLeaderboard(long id);
Task<Leaderboard?> GetLeaderboardBySlug(string slug);
Task<List<Leaderboard>> ListLeaderboards();
Task<List<Leaderboard>> ListLeaderboards(bool includeDeleted);
Task<CreateLeaderboardResult> CreateLeaderboard(CreateLeaderboardRequest request);
Task<RestoreLeaderboardResult> RestoreLeaderboard(long id);
Task<DeleteResult> DeleteLeaderboard(long id);
Expand Down
8 changes: 5 additions & 3 deletions LeaderboardBackend/Services/Impl/LeaderboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ await applicationContext.Leaderboards
.FirstOrDefaultAsync(b => b.Slug == slug && b.DeletedAt == null);

// FIXME: Paginate these
public async Task<List<Leaderboard>> ListLeaderboards() =>
await applicationContext.Leaderboards
.Where(lb => lb.DeletedAt == null).ToListAsync();
public async Task<List<Leaderboard>> ListLeaderboards(bool includeDeleted)
{
IQueryable<Leaderboard> lbs = applicationContext.Leaderboards;
return await (includeDeleted ? lbs : lbs.Where(lb => lb.DeletedAt == null)).ToListAsync();
}

public async Task<CreateLeaderboardResult> CreateLeaderboard(CreateLeaderboardRequest request)
{
Expand Down

0 comments on commit 42e3357

Please sign in to comment.