mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
Add StatisticsController, add /planetStats
This commit is contained in:
parent
075887b63c
commit
30e5d4e3b5
2 changed files with 39 additions and 10 deletions
|
@ -74,15 +74,5 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
|||
|
||||
return this.Ok("[{\"StatusCode\":200}]");
|
||||
}
|
||||
|
||||
[HttpGet("playersInPodCount")]
|
||||
[HttpGet("totalPlayerCount")]
|
||||
public async Task<IActionResult> TotalPlayerCount() {
|
||||
int recentMatches = await this.database.LastMatches
|
||||
.Where(l => TimestampHelper.Timestamp - l.Timestamp < 60)
|
||||
.CountAsync();
|
||||
|
||||
return this.Ok(recentMatches.ToString());
|
||||
}
|
||||
}
|
||||
}
|
39
ProjectLighthouse/Controllers/StatisticsController.cs
Normal file
39
ProjectLighthouse/Controllers/StatisticsController.cs
Normal file
|
@ -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<IActionResult> 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<IActionResult> 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)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue