diff options
Diffstat (limited to 'src/slskd/Telemetry/API/StatisticsController.cs')
| -rw-r--r-- | src/slskd/Telemetry/API/StatisticsController.cs | 32 |
1 files changed, 15 insertions, 17 deletions
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 } /// <summary> - /// Returns the top N errors by total count and direction. + /// Returns a list of transfer exceptions by 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> @@ -191,35 +191,33 @@ public class StatisticsController : ControllerBase /// <response code="500">An error occurred.</response> [HttpGet("transfers/exceptions")] [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(Dictionary<TransferDirection, List<TransferExceptionSummary>>), 200)] + [ProducesResponseType(typeof(List<TransferExceptionSummary>), 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<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 @@ -229,7 +227,7 @@ public class StatisticsController : ControllerBase end: end.Value, limit: limit, offset: offset, - direction: transferDirection, + direction: parsedDirection, username: username)); } catch (Exception ex) |
