namespace ZB.MOM.WW.ScadaBridge.Commons.Types;

/// <summary>
/// Point-in-time KPI snapshot for the central
/// Health dashboard's "Audit" tile group. Aggregates volume + error counts over
/// the trailing window from the central <c>AuditLog</c> table and combines them
/// with the global pending backlog summed across every site's
/// <see cref="SiteAuditBacklogSnapshot"/>.
/// </summary>
/// <param name="TotalEventsLastHour">
/// Total <c>AuditLog</c> rows whose <c>OccurredAtUtc</c> falls inside the trailing
/// 1-hour window. Drives the "Audit volume" tile and the denominator of
/// "Audit error rate". A zero value renders as "0" rather than an em dash —
/// "zero rows in the last hour" is a real, valid signal in a quiet system.
/// </param>
/// <param name="ErrorEventsLastHour">
/// Total <c>AuditLog</c> rows in the same window whose <see cref="Enums.AuditStatus"/>
/// is <c>Failed</c>, <c>Parked</c>, or <c>Discarded</c>. Drives the "Audit error
/// rate" tile numerator; clicking the tile drills in to <c>/audit/log</c>
/// pre-filtered on one of those statuses.
/// </param>
/// <param name="BacklogTotal">
/// Sum of <c>SiteAuditBacklog.PendingCount</c> across every site's latest
/// <see cref="ZB.MOM.WW.ScadaBridge.Commons.Messages.Health.SiteHealthReport"/>. Sites whose
/// snapshot is <c>null</c> (no report yet, or reporter not running) contribute
/// zero. A persistently non-zero value across multiple refresh ticks indicates
/// the site→central drain isn't keeping up.
/// </param>
/// <param name="AsOfUtc">
/// UTC timestamp at which the snapshot was computed. Used by the UI to label
/// "as of HH:mm:ss" beneath the tile group and to detect stale data when a
/// refresh tick fails.
/// </param>
public sealed record AuditLogKpiSnapshot(
    long TotalEventsLastHour,
    long ErrorEventsLastHour,
    long BacklogTotal,
    DateTime AsOfUtc);
