ProjectLighthouse/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs
W0lf4llo 9b014fa01c
StasticsHelper + Community Tab Performance Fix (#713)
* Player count shows per game

* Fixed LBP3 categories lagigng & StatisticsHelper

Co-authored-by: koko <sudokoko@users.noreply.github.com>

* Fixed "planetStats" mmPicksCount

* Hopefully the final update to this PR!
(Bug fixes)

* Update ProjectLighthouse/Types/Entities/Level/Slot.cs

Co-authored-by: koko <68549366+sudokoko@users.noreply.github.com>

* Update ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs

I'm trusting you that nothing breaks here lol

Co-authored-by: Josh <josh@slendy.pw>

* Update ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs

bad slendy >:(

Co-authored-by: koko <68549366+sudokoko@users.noreply.github.com>

---------

Co-authored-by: koko <sudokoko@users.noreply.github.com>
Co-authored-by: koko <68549366+sudokoko@users.noreply.github.com>
Co-authored-by: Josh <josh@slendy.pw>
2023-03-17 03:51:55 +00:00

45 lines
1.7 KiB
C#

using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using LBPUnion.ProjectLighthouse.Extensions;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[ApiController]
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/plain")]
public class StatisticsController : ControllerBase
{
private readonly DatabaseContext database;
public StatisticsController(DatabaseContext database)
{
this.database = database;
}
[HttpGet("playersInPodCount")]
public IActionResult PlayersInPodCount() => this.Ok((StatisticsHelper.UserCountInPod(this.database)).ToString());
[HttpGet("totalPlayerCount")]
public async Task<IActionResult> TotalPlayerCount() => this.Ok((await StatisticsHelper.RecentMatchesForGame(this.database, this.GetToken().GameVersion)).ToString());
[HttpGet("planetStats")]
public async Task<IActionResult> PlanetStats()
{
int totalSlotCount = await StatisticsHelper.SlotCountForGame(this.database, this.GetToken().GameVersion);
int mmPicksCount = await StatisticsHelper.TeamPickCountForGame(this.database, this.GetToken().GameVersion);
return this.Ok
(
LbpSerializer.StringElement
("planetStats", LbpSerializer.StringElement("totalSlotCount", totalSlotCount) + LbpSerializer.StringElement("mmPicksCount", mmPicksCount))
);
}
[HttpGet("planetStats/totalLevelCount")]
public async Task<IActionResult> TotalLevelCount() => this.Ok((await StatisticsHelper.SlotCountForGame(this.database, this.GetToken().GameVersion)).ToString());
}