feat(kpi): GetLatestRollupHourAsync watermark seam for the backfill fast-path (plan R2-04 T2)

This commit is contained in:
Joseph Doherty
2026-07-13 09:44:57 -04:00
parent 29c1286943
commit a1c7c4ef26
4 changed files with 54 additions and 0 deletions
@@ -192,6 +192,15 @@ public sealed class KpiHistoryRepository : IKpiHistoryRepository
.ToListAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<DateTime?> GetLatestRollupHourAsync(CancellationToken cancellationToken = default)
{
// Single MAX over the unique IX_KpiRollupHourly_Series population (the rollup
// table is small — one row per series-hour). Null when no rollups exist.
return await _context.KpiRollupHourly
.MaxAsync(r => (DateTime?)r.HourStartUtc, cancellationToken);
}
/// <inheritdoc />
public async Task PurgeRollupsOlderThanAsync(DateTime before, CancellationToken cancellationToken = default)
{