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/API/StatisticsController.cs | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/slskd/Telemetry/API') diff --git a/src/slskd/Telemetry/API/StatisticsController.cs b/src/slskd/Telemetry/API/StatisticsController.cs index ababddf2..302c0705 100644 --- a/src/slskd/Telemetry/API/StatisticsController.cs +++ b/src/slskd/Telemetry/API/StatisticsController.cs @@ -240,9 +240,9 @@ public class StatisticsController : ControllerBase /// /// Returns the top N exceptions by total count and 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). @@ -256,41 +256,39 @@ public class StatisticsController : ControllerBase [ProducesResponseType(typeof(string), 400)] [ProducesResponseType(typeof(string), 500)] public IActionResult GetTransferExceptionsPareto( + [FromQuery] string direction, [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 { return Ok(Telemetry.Statistics.GetTransferExceptionsPareto( + direction: parsedDirection, start: start.Value, end: end.Value, limit: limit, offset: offset, - direction: transferDirection, username: username)); } catch (Exception ex) -- cgit v1.2.3