test+chore: real-SQLite query coverage, batch detect writes, finish date centralization

Review follow-ups:
- (HIGH) Add real-SQLite round-trip tests for the new query methods so the load-bearing
  lexical O-format date ordering is verified, not just mocked: Anomaly
  ListByDateRange/CountSince, Snapshot CountSince/ListByEvents grouping, Event Query/GetMany.
- (MED) DetectAnomaliesUseCase: one SaveChanges per event instead of per anomaly.
- (LOW) Route PlacedBetRepository + ExcelExporter date bounds through SqliteDateText.
- (LOW) Backtest: reject a one-sided date range (was silently ignored).
- (LOW) Refresh stale comments after the detector fan-out.
This commit is contained in:
2026-05-29 01:25:25 +03:00
parent c9eee9f907
commit b67030ae7f
5 changed files with 107 additions and 11 deletions
@@ -40,10 +40,10 @@ internal sealed class PlacedBetRepository : IPlacedBetRepository
public async Task<IReadOnlyList<PlacedBet>> ListByDateRangeAsync(DateRange range, CancellationToken ct = default)
{
// PlacedAt is stored as ISO 8601 TEXT — same lexical-equals-chronological ordering
// trick used in EventRepository.ListByDateRangeAsync.
var fromStr = range.From.ToString("O");
var toStr = range.To.ToString("O");
// PlacedAt is stored via SqliteDateText (O-format TEXT) — same lexical-equals-
// chronological ordering used across the repositories.
var fromStr = SqliteDateText.Key(range.From);
var toStr = SqliteDateText.Key(range.To);
var entities = await _db.PlacedBets.AsNoTracking()
.Where(b => b.PlacedAt.CompareTo(fromStr) >= 0