texts fixes, search bar fixes, global menu fixes.
This commit is contained in:
@@ -903,6 +903,36 @@ static void ConfigureEndpoints(WebApplication app)
|
||||
.RequireAuthorization(NotifyPolicies.Viewer)
|
||||
.RequireRateLimiting(NotifyRateLimitPolicies.DeliveryHistory);
|
||||
|
||||
apiGroup.MapGet("/delivery/stats", async (
|
||||
IDeliveryRepository repository,
|
||||
HttpContext context,
|
||||
CancellationToken cancellationToken) =>
|
||||
{
|
||||
if (!TryResolveTenant(context, tenantHeader, out var tenant, out var error))
|
||||
{
|
||||
return error!;
|
||||
}
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var stats = await repository.GetStatsAsync(tenant!, now.AddHours(-24), now, cancellationToken);
|
||||
var totalCompleted = stats.Sent + stats.Delivered + stats.Failed + stats.Bounced;
|
||||
var successCount = stats.Sent + stats.Delivered;
|
||||
var rate = totalCompleted > 0 ? (double)successCount / totalCompleted * 100.0 : 0.0;
|
||||
|
||||
return Results.Ok(new
|
||||
{
|
||||
totalSent = stats.Sent + stats.Delivered,
|
||||
totalFailed = stats.Failed + stats.Bounced,
|
||||
totalPending = stats.Pending,
|
||||
successRate = Math.Round(rate, 1),
|
||||
windowHours = 24,
|
||||
evaluatedAt = now
|
||||
});
|
||||
})
|
||||
.WithName("NotifyDeliveryStats")
|
||||
.WithDescription("Get delivery statistics for the last 24 hours")
|
||||
.RequireAuthorization(NotifyPolicies.Viewer);
|
||||
|
||||
apiGroup.MapGet("/deliveries/{deliveryId}", async (
|
||||
string deliveryId,
|
||||
IDeliveryRepository repository,
|
||||
|
||||
Reference in New Issue
Block a user