From 92397eea18747ecae74726336f2a83796ecabad2 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 May 2025 01:19:08 +0200 Subject: [PATCH] Add Endpoint GET {steamId}/Total/{appId}" --- API/Controllers/TimeTrackController.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/API/Controllers/TimeTrackController.cs b/API/Controllers/TimeTrackController.cs index 3d04f7a..10162cb 100644 --- a/API/Controllers/TimeTrackController.cs +++ b/API/Controllers/TimeTrackController.cs @@ -54,6 +54,21 @@ public class TimeTrackController(Context databaseContext) : ApiController(typeof return Ok(sum); } + [HttpGet("{steamId}/Total/{appId}")] + [ProducesResponseType(Status200OK)] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetTrackedTimeAll(ulong steamId, ulong appId) + { + if (databaseContext.Players.Find(steamId) is not { } player) + return NotFound(); + if (databaseContext.Games.Find(appId) is not { } game) + return NotFound(); + databaseContext.Entry(player).Collection(p => p.TrackedTimes).Load(); + ulong? maxTime = player.TrackedTimes.Where(t => t.Game == game).MaxBy(t => t.TimePlayed)?.TimePlayed; + + return maxTime is not null ? Ok(maxTime) : NoContent(); + } + [HttpGet("{steamId}/Total/PerGame")] [ProducesResponseType[]>(Status200OK)] [ProducesResponseType(Status404NotFound)]