From 56b8301a25ce937fd7977ea84333097608244445 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Nov 2025 13:09:33 -0600 Subject: list requires direction --- src/slskd/Telemetry/API/StatisticsController.cs | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/slskd/Telemetry/API/StatisticsController.cs') diff --git a/src/slskd/Telemetry/API/StatisticsController.cs b/src/slskd/Telemetry/API/StatisticsController.cs index 5c6e55df..ababddf2 100644 --- a/src/slskd/Telemetry/API/StatisticsController.cs +++ b/src/slskd/Telemetry/API/StatisticsController.cs @@ -177,11 +177,11 @@ public class StatisticsController : ControllerBase } /// - /// Returns the top N errors by total count and direction. + /// Returns a list of transfer exceptions by direction. /// + /// The direction by which to filter activity. /// The start time. /// The end time. - /// An optional direction by which to filter activity. /// An optional username by which to filter exceptions. /// The number of records to return (Default: 25). /// The record offset (if paginating). @@ -191,35 +191,33 @@ public class StatisticsController : ControllerBase /// An error occurred. [HttpGet("transfers/exceptions")] [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(Dictionary>), 200)] + [ProducesResponseType(typeof(List), 200)] [ProducesResponseType(typeof(string), 400)] [ProducesResponseType(typeof(string), 500)] public IActionResult GetTransferExceptions( + [FromQuery] string direction = null, [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, - [FromQuery] string direction = null, [FromQuery] string username = null, [FromQuery] int limit = 25, [FromQuery] int offset = 0) { - start ??= DateTime.MinValue; - end ??= DateTime.MaxValue; + if (string.IsNullOrWhiteSpace(direction)) + { + return BadRequest("Direction is required"); + } - if (start >= end) + if (!Enum.TryParse(direction, ignoreCase: true, out var parsedDirection)) { - return BadRequest("End time must be later than start time"); + return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); } - TransferDirection? transferDirection = null; + start ??= DateTime.MinValue; + end ??= DateTime.MaxValue; - if (!string.IsNullOrWhiteSpace(direction)) + if (start >= end) { - if (!Enum.TryParse(direction, ignoreCase: true, out var parsedDirection)) - { - return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); - } - - transferDirection = parsedDirection; + return BadRequest("End time must be later than start time"); } try @@ -229,7 +227,7 @@ public class StatisticsController : ControllerBase end: end.Value, limit: limit, offset: offset, - direction: transferDirection, + direction: parsedDirection, username: username)); } catch (Exception ex) -- cgit v1.2.3