feat(bp): /battle_pass/info — service + controller + 3 tests

Also fixes BattlePassRepository.GetActiveSeasonAsync to use client-side
DateTimeOffset filtering (SQLite provider cannot translate DateTimeOffset
comparisons in LINQ WHERE/ORDER BY clauses).
This commit is contained in:
gamer147
2026-05-26 23:14:26 -04:00
parent 6ed61ea9f1
commit 8a35f8c40b
5 changed files with 280 additions and 12 deletions

View File

@@ -18,11 +18,17 @@ public sealed class BattlePassRepository : IBattlePassRepository
public async Task<BattlePassSeasonEntry?> GetActiveSeasonAsync(DateTimeOffset when, CancellationToken ct)
{
return await _db.BattlePassSeasons
// Use UtcDateTime for the LINQ comparison so the query translates on both Postgres and
// SQLite. DateTimeOffset arithmetic in LINQ isn't supported by the SQLite provider;
// DateTime (UTC) is stored and compared as ISO-8601 text which SQLite handles fine.
var utcNow = when.UtcDateTime;
var candidates = await _db.BattlePassSeasons
.AsNoTracking()
.Where(s => s.StartDate <= when && s.EndDate > when)
.ToListAsync(ct);
return candidates
.Where(s => s.StartDate.UtcDateTime <= utcNow && s.EndDate.UtcDateTime > utcNow)
.OrderByDescending(s => s.StartDate)
.FirstOrDefaultAsync(ct);
.FirstOrDefault();
}
public Task<BattlePassSeasonEntry?> GetSeasonAsync(int seasonId, CancellationToken ct) =>