ProjectLighthouse/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs
W0lf4llo aefecc7b12
Make LBP2 lucky dip prefer newer levels and make player count more accurate (#744)
* Lucky Dip, Newest Levels, & Recently Played change

* almost broke prod :disaster:

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

I forgor lol

Co-authored-by: koko <koko@drones.gay>

* Remove TimestampMicros and add random slot selection with bias

* playersInPod count filters by platform

* Hope this actually commits now, idk github

* Apply suggestions from code review

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

* Update ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs

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

* Fix random bias ordering

---------

Co-authored-by: koko <joebiden@kitgaming67.com>
Co-authored-by: koko <koko@drones.gay>
Co-authored-by: Slendy <josh@slendy.pw>
2023-04-29 04:32:36 +00:00

43 lines
1.6 KiB
C#

using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users;
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.RoomCountForPlatform(this.GetToken().Platform).ToString());
[HttpGet("totalPlayerCount")]
public async Task<IActionResult> TotalPlayerCount() => this.Ok((await StatisticsHelper.RecentMatchesForGame(this.database, this.GetToken().GameVersion)).ToString());
[HttpGet("planetStats")]
[Produces("text/xml")]
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(new PlanetStatsResponse(totalSlotCount, mmPicksCount));
}
[HttpGet("planetStats/totalLevelCount")]
public async Task<IActionResult> TotalLevelCount() => this.Ok((await StatisticsHelper.SlotCountForGame(this.database, this.GetToken().GameVersion)).ToString());
}