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:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user