initial commit
This commit is contained in:
commit
2d966b8198
28 changed files with 2901 additions and 0 deletions
21
Pages/Index.cshtml.cs
Normal file
21
Pages/Index.cshtml.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using CsWeb.Services;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace CsWeb.Pages;
|
||||
|
||||
public class IndexModel(Fleet fleet) : PageModel
|
||||
{
|
||||
public Fleet Fleet => fleet;
|
||||
public List<(string Id, Cached<StatusPayload> Status)> Servers { get; private set; } = [];
|
||||
public int HumansOnline { get; private set; }
|
||||
public int ServersUp { get; private set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var ids = fleet.Instances();
|
||||
var fetched = await Task.WhenAll(ids.Select(fleet.Status));
|
||||
Servers = ids.Zip(fetched, (id, s) => (id, s)).ToList();
|
||||
HumansOnline = Servers.Sum(s => s.Status.Online ? s.Status.Data?.Humans.Count ?? 0 : 0);
|
||||
ServersUp = Servers.Count(s => s.Status.Online);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue