diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-11-30 13:13:06 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-11-30 13:13:06 -0600 |
| commit | cd671b78c29f8eb90f906fdbfc0ee7a87d66a3ca (patch) | |
| tree | b3480a50013bc80af0394616b12c8992fb791c1f /src/slskd/Telemetry/API | |
| parent | 56b8301a25ce937fd7977ea84333097608244445 (diff) | |
| download | slskd-cd671b78c29f8eb90f906fdbfc0ee7a87d66a3ca.tar.gz | |
require direction for pareto
Diffstat (limited to 'src/slskd/Telemetry/API')
| -rw-r--r-- | src/slskd/Telemetry/API/StatisticsController.cs | 28 |
1 files changed, 13 insertions, 15 deletions
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 /// <summary> /// Returns the top N exceptions by total count and direction. /// </summary> + /// <param name="direction">The direction by which to filter activity.</param> /// <param name="start">The start time.</param> /// <param name="end">The end time.</param> - /// <param name="direction">An optional direction by which to filter activity.</param> /// <param name="username">An optional username by which to filter exceptions.</param> /// <param name="limit">The number of records to return (Default: 25).</param> /// <param name="offset">The record offset (if paginating).</param> @@ -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<TransferDirection>(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<TransferDirection>(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) |
