mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-10 12:12:27 +00:00
Remove InfluxDB and add /api/v1/playerCount (#664)
* Add /playerCount api * Modify /playerCount api response * Remove all InfluxDB components
This commit is contained in:
parent
e93aea1977
commit
c8120b3388
9 changed files with 51 additions and 142 deletions
|
@ -1,6 +1,6 @@
|
|||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||
using LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
|
||||
|
@ -36,4 +36,39 @@ public class StatisticsEndpoints : ApiEndpointController
|
|||
TeamPicks = await StatisticsHelper.TeamPickCount(this.database),
|
||||
}
|
||||
);
|
||||
|
||||
private static readonly List<GameVersion> gameVersions = new()
|
||||
{
|
||||
GameVersion.LittleBigPlanet1,
|
||||
GameVersion.LittleBigPlanet2,
|
||||
GameVersion.LittleBigPlanet3,
|
||||
GameVersion.LittleBigPlanetVita,
|
||||
GameVersion.LittleBigPlanetPSP,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Get player counts for each individual title
|
||||
/// </summary>
|
||||
/// <returns>An instance of PlayerCountResponse</returns>
|
||||
[HttpGet("playerCount")]
|
||||
[ProducesResponseType(typeof(PlayerCountResponse), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetPlayerCounts()
|
||||
{
|
||||
List<PlayerCountObject> gameList = new();
|
||||
foreach (GameVersion version in gameVersions)
|
||||
{
|
||||
gameList.Add(new PlayerCountObject
|
||||
{
|
||||
Game = version.ToString(),
|
||||
PlayerCount = await StatisticsHelper.RecentMatchesForGame(this.database, version),
|
||||
});
|
||||
}
|
||||
PlayerCountResponse response = new()
|
||||
{
|
||||
TotalPlayerCount = await StatisticsHelper.RecentMatches(this.database),
|
||||
Games = gameList,
|
||||
};
|
||||
|
||||
return this.Ok(response);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue