Skip to content

Commit df16e51

Browse files
committed
Prevent throughput report from breaking if there is more than one source of the same type
1 parent f65a99f commit df16e51

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Particular.LicensingComponent/ThroughputDataExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
static class ThroughputDataExtensions
66
{
77
public static IEnumerable<EndpointDailyThroughput> FromSource(this List<ThroughputData> throughputs, ThroughputSource source) => throughputs
8-
.SingleOrDefault(td => td.ThroughputSource == source)?
9-
.Select(kvp => new EndpointDailyThroughput(kvp.Key, kvp.Value)) ?? [];
8+
.Where(td => td.ThroughputSource == source)
9+
.SelectMany(td => td)
10+
.Select(kvp => new EndpointDailyThroughput(kvp.Key, kvp.Value));
1011

1112
public static long Sum(this List<ThroughputData> throughputs) => throughputs.SelectMany(t => t).Sum(kvp => kvp.Value);
1213

@@ -40,4 +41,4 @@ public static long MaxMonthlyThroughput(this List<ThroughputData> throughputs)
4041

4142
public static bool HasDataFromSource(this IDictionary<string, IEnumerable<ThroughputData>> throughputPerQueue, ThroughputSource source) =>
4243
throughputPerQueue.Any(queueName => queueName.Value.Any(data => data.ThroughputSource == source && data.Count > 0));
43-
}
44+
}

0 commit comments

Comments
 (0)