diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-09-07 18:28:17 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-09-07 18:28:17 -0500 |
| commit | 15d47430f10bb2f9f577d784767e15e50ae2846c (patch) | |
| tree | 678c14e7b8f0c971874077babd69fca4abc9d531 | |
| parent | 0c395f46df8b966d149fbcba697b026b1605b62c (diff) | |
| download | slskd-15d47430f10bb2f9f577d784767e15e50ae2846c.tar.gz | |
change names, remove duplicated endpoint
| -rw-r--r-- | src/slskd/Telemetry/API/TelemetryController.cs | 14 | ||||
| -rw-r--r-- | src/slskd/Telemetry/StatisticsService.cs | 20 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/slskd/Telemetry/API/TelemetryController.cs b/src/slskd/Telemetry/API/TelemetryController.cs index a02b3e05..c725575c 100644 --- a/src/slskd/Telemetry/API/TelemetryController.cs +++ b/src/slskd/Telemetry/API/TelemetryController.cs @@ -167,8 +167,8 @@ public class TelemetryController : ControllerBase return BadRequest("Offset must be greater than or equal to zero"); } - var downloads = Telemetry.Statistics.GetSuccessfulTransferSummaryByDirectionAndUsername(direction: TransferDirection.Download, start.Value, end, limit: limit.Value, offset: offset.Value); - var uploads = Telemetry.Statistics.GetSuccessfulTransferSummaryByDirectionAndUsername(direction: TransferDirection.Upload, start.Value, end, limit: limit.Value, offset: offset.Value); + var downloads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Download, start.Value, end, limit: limit.Value, offset: offset.Value); + var uploads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Upload, start.Value, end, limit: limit.Value, offset: offset.Value); var dict = new Dictionary<TransferDirection, List<TransferSummary>>() { @@ -227,14 +227,4 @@ public class TelemetryController : ControllerBase return Ok(dict); } - - [HttpGet("statistics/transfers/errors")] - [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(UserSummary), 200)] - public IActionResult GetUserStatistics( - [FromQuery] string username) - { - // todo: return everything we know about this user - return Ok(); - } } diff --git a/src/slskd/Telemetry/StatisticsService.cs b/src/slskd/Telemetry/StatisticsService.cs index ae072685..24d513b9 100644 --- a/src/slskd/Telemetry/StatisticsService.cs +++ b/src/slskd/Telemetry/StatisticsService.cs @@ -126,7 +126,7 @@ public class StatisticsService /// <exception cref="ArgumentException"> /// Thrown if end time is not later than start time, or limit is not greater than zero. /// </exception> - public List<TransferSummary> GetSuccessfulTransferSummaryByDirectionAndUsername( + public List<TransferSummary> GetTransferRanking( TransferDirection direction, DateTime? start = null, DateTime? end = null, @@ -193,6 +193,19 @@ public class StatisticsService return list; } + /// <summary> + /// Returns a summary of distinct transfer errors and the number of times they occurred. + /// </summary> + /// <param name="start">The optional start time of the summary window.</param> + /// <param name="end">The optional end time of the summary window.</param> + /// <param name="direction">The direction (Upload or Download) for the summary.</param> + /// <param name="username">The optional username by which to filter results.</param> + /// <param name="limit">The number of records to return (default: 25).</param> + /// <param name="offset">The record offset (if paginating).</param> + /// <returns></returns> + /// <exception cref="ArgumentException"> + /// Thrown if end time is not later than start time, or limit is not greater than zero. + /// </exception> public Dictionary<string, long> GetTransferErrorSummary( DateTime? start = null, DateTime? end = null, @@ -209,6 +222,11 @@ public class StatisticsService throw new ArgumentException("End time must be later than start time"); } + if (limit <= 0) + { + throw new ArgumentOutOfRangeException("Limit must be greater than zero"); + } + var dict = new Dictionary<string, long>(); var sql = @$" |
