Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ await DataStore.CreateBuilder()
}
}

[Test]
[SetCulture("th-TH")]
public async Task Should_key_monthly_throughput_by_gregorian_month_when_the_culture_uses_another_calendar()
{
await DataStore.CreateBuilder()
.AddEndpoint("Endpoint1", sources: [ThroughputSource.Broker])
.WithThroughput(new ThroughputData([
new EndpointDailyThroughput(new DateOnly(2025, 1, 10), 50),
new EndpointDailyThroughput(new DateOnly(2025, 2, 20), 60)]))
.Build();

var summary = await ThroughputCollector.GetThroughputSummary(CancellationToken.None);

Assert.That(summary.Single().MonthlyThroughput, Is.EquivalentTo(new[] { new MonthlyThroughput("2025-01", 50), new MonthlyThroughput("2025-02", 60) }), "Monthly throughput must be keyed by Gregorian yyyy-MM months");
}

[Test]
public async Task Should_return_correct_max_daily_throughput_in_summary_when_endpoint_has_zero_throughput()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Particular.LicensingComponent;

using System.Globalization;
using Contracts;

static class ThroughputDataExtensions
Expand Down Expand Up @@ -29,7 +30,7 @@ public static MonthlyThroughput[] MonthlyThroughput(this List<ThroughputData> th
.Where(x => x.Value >= 0)
.GroupBy(x => x.Key, x => x.Value)
.ToLookup(x => x.Key, x => x.Max())
.GroupBy(kvp => $"{kvp.Key:yyyy-MM}", x => x.Sum())
.GroupBy(kvp => kvp.Key.ToString("yyyy-MM", CultureInfo.InvariantCulture), x => x.Sum())
.Select(group => new MonthlyThroughput(group.Key, group.Sum()))];

public static long AverageMonthlyThroughput(this List<ThroughputData> throughputs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Particular.LicensingComponent.WebApi
{
using System.Globalization;
using System.IO.Compression;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -66,7 +67,7 @@ public async Task GetThroughputReportFile([FromQuery(Name = "spVersion")] string
null,
cancellationToken);

var fileName = $"{report.ReportData.CustomerName}.throughput-report-{report.ReportData.EndTime:yyyyMMdd-HHmmss}";
var fileName = $"{report.ReportData.CustomerName}.throughput-report-{report.ReportData.EndTime.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture)}";

HttpContext.Response.ContentType = "application/zip";
HttpContext.Response.Headers[HeaderNames.ContentDisposition] = new ContentDispositionHeaderValue("attachment")
Expand Down
Loading