aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Telemetry/API/StatisticsController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Telemetry/API/StatisticsController.cs')
-rw-r--r--src/slskd/Telemetry/API/StatisticsController.cs28
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)