From a2b2f88fad4562006453de88fe82005324dcfb8c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Nov 2025 13:08:16 -0600 Subject: require direction for list --- src/slskd/Telemetry/StatisticsService.cs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/slskd/Telemetry/StatisticsService.cs b/src/slskd/Telemetry/StatisticsService.cs index a5e55a9b..7db44893 100644 --- a/src/slskd/Telemetry/StatisticsService.cs +++ b/src/slskd/Telemetry/StatisticsService.cs @@ -219,20 +219,20 @@ public class StatisticsService /// /// Returns a list of transfer exceptions. /// + /// The direction (Upload or Download). /// 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). - /// A dictionary keyed by direction and containing a list of exceptions and the number of times they occurred. + /// A list of exceptions. /// /// Thrown if end time is not later than start time, or limit is not greater than zero. /// - public Dictionary> GetTransferExceptions( + public List GetTransferExceptions( + TransferDirection direction, DateTime? start = null, DateTime? end = null, - TransferDirection? direction = null, string username = null, int limit = 25, int offset = 0) @@ -245,12 +245,6 @@ 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 Id, @@ -273,9 +267,8 @@ public class StatisticsService END as Exception 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 ORDER BY EndedAt DESC LIMIT @Limit OFFSET @Offset @@ -294,15 +287,7 @@ public class StatisticsService }; var results = connection.Query(sql, param); - - Log.Debug("Result rows for {Method}, filters: {Params}: {Count}", nameof(GetTransferExceptions), param, results?.Count()); - - foreach (var result in results) - { - dict[result.Direction].Add(result); - } - - return dict; + return results.ToList(); } /// -- cgit v1.2.3