diff --git a/ProjectLighthouse/Controllers/MatchController.cs b/ProjectLighthouse/Controllers/MatchController.cs index 5b14bf76..a5aec1cb 100644 --- a/ProjectLighthouse/Controllers/MatchController.cs +++ b/ProjectLighthouse/Controllers/MatchController.cs @@ -74,15 +74,5 @@ namespace LBPUnion.ProjectLighthouse.Controllers { return this.Ok("[{\"StatusCode\":200}]"); } - - [HttpGet("playersInPodCount")] - [HttpGet("totalPlayerCount")] - public async Task TotalPlayerCount() { - int recentMatches = await this.database.LastMatches - .Where(l => TimestampHelper.Timestamp - l.Timestamp < 60) - .CountAsync(); - - return this.Ok(recentMatches.ToString()); - } } } \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/StatisticsController.cs b/ProjectLighthouse/Controllers/StatisticsController.cs new file mode 100644 index 00000000..d71a9222 --- /dev/null +++ b/ProjectLighthouse/Controllers/StatisticsController.cs @@ -0,0 +1,39 @@ +using System.Linq; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Serialization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Controllers { + [ApiController] + [Route("LITTLEBIGPLANETPS3_XML/")] + [Produces("text/plain")] + public class StatisticsController : ControllerBase { + private readonly Database database; + public StatisticsController(Database database) { + this.database = database; + } + + [HttpGet("playersInPodCount")] + [HttpGet("totalPlayerCount")] + public async Task TotalPlayerCount() { + int recentMatches = await this.database.LastMatches + .Where(l => TimestampHelper.Timestamp - l.Timestamp < 60) + .CountAsync(); + + return this.Ok(recentMatches.ToString()); + } + + [HttpGet("planetStats")] + public async Task PlanetStats() { + int totalSlotCount = await this.database.Slots.CountAsync(); + const int mmPicksCount = 0; + + return this.Ok(LbpSerializer.StringElement("planetStats", + LbpSerializer.StringElement("totalSlotCount", totalSlotCount) + + LbpSerializer.StringElement("mmPicksCount", mmPicksCount) + )); + } + } +} \ No newline at end of file