ProjectLighthouse/ProjectLighthouse/Helpers/StatisticsHelper.cs
Zaprit ce0fe9edee
Added user invite system (#351)
* Added user invite system

* Added user invite system

* Revert recent migrations and try again

* stopped implicitly assigning token variables

* Added correct context to migrations

* Apply suggestions from code review

Some grammar changes, etc.

Co-authored-by: Jayden <jvyden@jvyden.xyz>

* Updated the API key page

* Removed enabled field from APIKey

* Removed reference to APIKey.Enabled

* Add creation guide text

* Fix this.Forbid() usage

Causes an exception on my machine for some reason, always has.

* Fix more forbid usages

* Return 404 if trying to generate token when private registration is disabled

* Capture authentication schema more cleanly

Co-authored-by: Jayden <jvyden@jvyden.xyz>
2022-07-24 02:43:00 +00:00

30 lines
No EOL
1.2 KiB
C#

using System.Linq;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.PlayerData;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Helpers;
public static class StatisticsHelper
{
private static readonly Database database = new();
public static async Task<int> RecentMatches() => await database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300).CountAsync();
public static async Task<int> RecentMatchesForGame
(GameVersion gameVersion)
=> await database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300 && l.GameVersion == gameVersion).CountAsync();
public static async Task<int> SlotCount() => await database.Slots.CountAsync();
public static async Task<int> UserCount() => await database.Users.CountAsync(u => !u.Banned);
public static async Task<int> TeamPickCount() => await database.Slots.CountAsync(s => s.TeamPick);
public static async Task<int> PhotoCount() => await database.Photos.CountAsync();
public static async Task<int> ReportCount() => await database.Reports.CountAsync();
public static async Task<int> APIKeyCount() => await database.APIKeys.CountAsync();
}