diff --git a/src/ScadaLink.Commons/Messages/Notification/NotificationOutboxQueries.cs b/src/ScadaLink.Commons/Messages/Notification/NotificationOutboxQueries.cs index 6fbb1b2..20f68d9 100644 --- a/src/ScadaLink.Commons/Messages/Notification/NotificationOutboxQueries.cs +++ b/src/ScadaLink.Commons/Messages/Notification/NotificationOutboxQueries.cs @@ -1,3 +1,5 @@ +using ScadaLink.Commons.Types.Notifications; + namespace ScadaLink.Commons.Messages.Notification; /// @@ -94,3 +96,20 @@ public record NotificationKpiResponse( int ParkedCount, int DeliveredLastInterval, TimeSpan? OldestPendingAge); + +/// +/// Outbox UI -> Central: request for the per-source-site notification outbox KPI breakdown. +/// +public record PerSiteNotificationKpiRequest( + string CorrelationId); + +/// +/// Central -> Outbox UI: per-site KPI breakdown for the Notification KPIs page. +/// On a repository fault is false, +/// carries the cause, and is empty. +/// +public record PerSiteNotificationKpiResponse( + string CorrelationId, + bool Success, + string? ErrorMessage, + IReadOnlyList Sites); diff --git a/tests/ScadaLink.Commons.Tests/Messages/NotificationMessagesTests.cs b/tests/ScadaLink.Commons.Tests/Messages/NotificationMessagesTests.cs index 2b171c8..f68996f 100644 --- a/tests/ScadaLink.Commons.Tests/Messages/NotificationMessagesTests.cs +++ b/tests/ScadaLink.Commons.Tests/Messages/NotificationMessagesTests.cs @@ -1,4 +1,5 @@ using ScadaLink.Commons.Messages.Notification; +using ScadaLink.Commons.Types.Notifications; namespace ScadaLink.Commons.Tests.Messages; @@ -187,4 +188,26 @@ public class NotificationMessagesTests var msg = new NotificationKpiRequest("corr-1"); Assert.Equal("corr-1", msg.CorrelationId); } + + [Fact] + public void PerSiteNotificationKpiRequest_CarriesCorrelationId() + { + var request = new PerSiteNotificationKpiRequest("corr-1"); + Assert.Equal("corr-1", request.CorrelationId); + } + + [Fact] + public void PerSiteNotificationKpiResponse_CarriesPerSiteSnapshots() + { + var sites = new[] + { + new SiteNotificationKpiSnapshot("plant-a", 3, 1, 0, 10, TimeSpan.FromMinutes(4)), + }; + var response = new PerSiteNotificationKpiResponse("corr-1", Success: true, ErrorMessage: null, sites); + + Assert.True(response.Success); + Assert.Null(response.ErrorMessage); + Assert.Single(response.Sites); + Assert.Equal("plant-a", response.Sites[0].SourceSiteId); + } }