diff --git a/API/Controllers/TimeTrackController.cs b/API/Controllers/TimeTrackController.cs index 3bcfde9..2677a45 100644 --- a/API/Controllers/TimeTrackController.cs +++ b/API/Controllers/TimeTrackController.cs @@ -8,6 +8,21 @@ namespace API.Controllers; [Route("[controller]")] public class TimeTrackController(Context databaseContext) : ApiController(typeof(TimeTrackController)) { + + [HttpGet("{steamId}")] + [ProducesResponseType>(Status200OK)] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetTrackedTime(ulong steamId) + { + if (databaseContext.Players.Find(steamId) is not { } player) + return NotFound(); + databaseContext.Entry(player).Collection(p => p.TrackedTimes).Load(); + Dictionary ret = player.TrackedTimes + .GroupBy(t => t.Game) + .ToDictionary(t => t.Key.AppId, t => t.ToArray()); + return Ok(ret); + } + [HttpGet("{steamId}/{appId}")] [ProducesResponseType(Status200OK)] [ProducesResponseType(Status404NotFound)] @@ -38,7 +53,7 @@ public class TimeTrackController(Context databaseContext) : ApiController(typeof return Ok(sum); } - [HttpGet("{steamId}/PerGame")] + [HttpGet("{steamId}/Total/PerGame")] [ProducesResponseType>(Status200OK)] [ProducesResponseType(Status404NotFound)] public IActionResult GetTrackedTimeAll(ulong steamId)