fix(kpi-history): backlogTotal trend records the real site-backlog aggregate instead of a hardwired zero

This commit is contained in:
Joseph Doherty
2026-07-09 07:51:55 -04:00
parent 1dd993ec2f
commit 1b53de1933
6 changed files with 271 additions and 3 deletions
@@ -0,0 +1,33 @@
namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Kpi;
/// <summary>
/// Supplies the system-wide pending Audit Log backlog for the
/// <c>backlogTotal</c> KPI history sample ("KPI History &amp; Trends").
/// </summary>
/// <remarks>
/// <para>
/// The append-only Audit Log repository leaves <c>AuditLogKpiSnapshot.BacklogTotal</c>
/// at zero — the backlog is not a central-table count but the sum of the latest
/// per-site <c>SiteAuditBacklog.PendingCount</c> health reports, which live only in
/// the in-memory central health aggregator. The live Health-dashboard "Audit" tile
/// already fills this in (<c>AuditLogQueryService.GetKpiSnapshotAsync</c>); this seam
/// lets the KPI <em>history</em> sample source read the same aggregate instead of
/// persisting a hardwired zero.
/// </para>
/// <para>
/// Best-effort: sites that have not yet reported (or whose reporter is disabled)
/// contribute zero — a missing snapshot is treated as "unknown, count as nothing",
/// mirroring the live tile. Central-only: registered on the central node where the
/// health aggregator lives; sites and unit tests leave it unregistered so the
/// sample source falls back to the snapshot's own <c>BacklogTotal</c>.
/// </para>
/// </remarks>
public interface IAuditBacklogProvider
{
/// <summary>
/// Returns the current total pending (not-yet-forwarded) Audit Log backlog,
/// summed across every site's latest health report. Never negative; zero when
/// no site is reporting a backlog.
/// </summary>
long GetPendingBacklogTotal();
}