forked from SoDOff-Project/sodoff
add stats endpoint
This commit is contained in:
parent
3a58938f59
commit
d3b7270dcd
@ -1,9 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using sodoff.Model;
|
||||
|
||||
namespace sodoff.Controllers.Common
|
||||
{
|
||||
public class AnalyticsController : Controller
|
||||
{
|
||||
private readonly DBContext ctx;
|
||||
public AnalyticsController(DBContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("AnalyticsWebService.asmx/GetUserAndVikingCount")]
|
||||
public IActionResult GetUserAndVikingCount([FromForm] bool vikingsOnly)
|
||||
{
|
||||
if (vikingsOnly) return Ok(new UserStatistics
|
||||
{
|
||||
VikingCount = ctx.Vikings.Count(e => e.Id > 0)
|
||||
});
|
||||
else return Ok(new UserStatistics
|
||||
{
|
||||
VikingCount = ctx.Vikings.Count(),
|
||||
UserCount = ctx.Users.Count(),
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("AnalyticsWebService.asmx/LogEvent")]
|
||||
@ -20,4 +42,10 @@ namespace sodoff.Controllers.Common
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
public class UserStatistics
|
||||
{
|
||||
public int VikingCount { get; set; }
|
||||
public int? UserCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user