From 12ac48516cd06d5dad2b4ba99bc38ed60ff000b6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 1 Sep 2025 12:31:31 -0500 Subject: add offset to support pagination --- src/slskd/Telemetry/StatisticsService.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/slskd/Telemetry/StatisticsService.cs b/src/slskd/Telemetry/StatisticsService.cs index 52299c9d..26ffaf2b 100644 --- a/src/slskd/Telemetry/StatisticsService.cs +++ b/src/slskd/Telemetry/StatisticsService.cs @@ -120,15 +120,17 @@ public class StatisticsService /// The optional start time of the summary window. /// The optional end time of the summary window. /// The number of records to return (default: 25). + /// The record offset (if paginating). /// A dictionary keyed by username and containing summary information. /// /// Thrown if end time is not later than start time, or limit is not greater than zero. /// - public Dictionary GetSuccessfulTransferSummaryByDirectionAndUsername( + public List GetSuccessfulTransferSummaryByDirectionAndUsername( TransferDirection direction, DateTime? start = null, DateTime? end = null, - int limit = 25) + int limit = 25, + int offset = 0) { start ??= DateTime.MinValue; end ??= DateTime.MaxValue; @@ -143,8 +145,6 @@ public class StatisticsService throw new ArgumentOutOfRangeException("Limit must be greater than zero"); } - var dict = new Dictionary(); - var sql = @$" SELECT Username, @@ -161,8 +161,9 @@ public class StatisticsService AND EndedAt IS NOT NULL AND EndedAt BETWEEN @Start AND @End GROUP BY Username, Direction, StateDescription - ORDER BY Count DESC + ORDER BY Count DESC, TotalBytes DESC, Username ASC LIMIT @Limit + OFFSET @Offset "; using var connection = new SqliteConnection(ConnectionStrings[Database.Transfers]); -- cgit v1.2.3