Get Timelines for All Games
This commit is contained in:
parent
86642b5d28
commit
7f7817bb64
@ -8,6 +8,21 @@ namespace API.Controllers;
|
|||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
public class TimeTrackController(Context databaseContext) : ApiController(typeof(TimeTrackController))
|
public class TimeTrackController(Context databaseContext) : ApiController(typeof(TimeTrackController))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[HttpGet("{steamId}")]
|
||||||
|
[ProducesResponseType<Dictionary<ulong, TrackedTime[]>>(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<ulong, TrackedTime[]> ret = player.TrackedTimes
|
||||||
|
.GroupBy(t => t.Game)
|
||||||
|
.ToDictionary(t => t.Key.AppId, t => t.ToArray());
|
||||||
|
return Ok(ret);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("{steamId}/{appId}")]
|
[HttpGet("{steamId}/{appId}")]
|
||||||
[ProducesResponseType<TrackedTime[]>(Status200OK)]
|
[ProducesResponseType<TrackedTime[]>(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
@ -38,7 +53,7 @@ public class TimeTrackController(Context databaseContext) : ApiController(typeof
|
|||||||
return Ok(sum);
|
return Ok(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{steamId}/PerGame")]
|
[HttpGet("{steamId}/Total/PerGame")]
|
||||||
[ProducesResponseType<Dictionary<ulong, ulong>>(Status200OK)]
|
[ProducesResponseType<Dictionary<ulong, ulong>>(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetTrackedTimeAll(ulong steamId)
|
public IActionResult GetTrackedTimeAll(ulong steamId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user