using Febe.Core.Domain; using Febe.Core.Storage; namespace Febe.Web.Engine; /// The stops of the last days for the Dashboard (spec §7.6 still says «nella cronologia della pagina Attività», the page before it). public interface IIncidentHistory { /// Incidents that started in [from, to), newest first. Task> ListAsync(DateTimeOffset from, DateTimeOffset to, CancellationToken ct); } /// The incidents of the database (table incident). public sealed class StoredIncidentHistory(IFebeStorage storage) : IIncidentHistory { public async Task> ListAsync(DateTimeOffset from, DateTimeOffset to, CancellationToken ct) { var list = await storage.Incidents.ListAsync(from, to, ct).ConfigureAwait(false); return [.. list.OrderByDescending(i => i.At)]; } }