From cd671b78c29f8eb90f906fdbfc0ee7a87d66a3ca Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Nov 2025 13:13:06 -0600 Subject: require direction for pareto --- src/slskd/Telemetry/StatisticsService.cs | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/slskd/Telemetry/StatisticsService.cs') diff --git a/src/slskd/Telemetry/StatisticsService.cs b/src/slskd/Telemetry/StatisticsService.cs index 7db44893..3bd9b26b 100644 --- a/src/slskd/Telemetry/StatisticsService.cs +++ b/src/slskd/Telemetry/StatisticsService.cs @@ -293,9 +293,9 @@ public class StatisticsService /// /// Returns a summary of distinct transfer exceptions and the number of times they occurred. /// + /// The direction (Upload or Download) for the summary. /// The optional start time of the summary window. /// The optional end time of the summary window. - /// The direction (Upload or Download) for the summary. /// The optional username by which to filter results. /// The number of records to return (default: 25). /// The record offset (if paginating). @@ -303,10 +303,10 @@ public class StatisticsService /// /// Thrown if end time is not later than start time, or limit is not greater than zero. /// - public Dictionary> GetTransferExceptionsPareto( + public List GetTransferExceptionsPareto( + TransferDirection direction, DateTime? start = null, DateTime? end = null, - TransferDirection? direction = null, string username = null, int limit = 25, int offset = 0) @@ -319,15 +319,8 @@ public class StatisticsService throw new ArgumentException("End time must be later than start time"); } - var dict = new Dictionary>() - { - { TransferDirection.Download, new List() }, - { TransferDirection.Upload, new List() }, - }; - var sql = @$" SELECT - Direction, CASE WHEN INSTR(Exception, ':') > 0 THEN SUBSTR(Exception, INSTR(Exception, ':') + 2) @@ -337,7 +330,7 @@ public class StatisticsService COUNT(DISTINCT Username) as DistinctUsers FROM transfers WHERE state & ~48 - {(direction is not null ? "AND Direction = @Direction" : string.Empty)} + AND Direction = @Direction {(username is not null ? "AND Username = @Username" : string.Empty)} GROUP BY Direction, CASE @@ -362,19 +355,8 @@ public class StatisticsService Offset = offset, }; - var results = connection.Query(sql, param); - - foreach (var result in results) - { - dict[result.Direction].Add(new TransferExceptionSummary - { - Exception = result.Exception, - Count = result.Count, - DistinctUsers = result.DistinctUsers, - }); - } - - return dict; + var results = connection.Query(sql, param); + return results.ToList(); } /// -- cgit v1.2.3