Rename LastMatch to LastContact

This commit is contained in:
jvyden 2021-12-02 18:44:44 -05:00
commit eb4d0c6f67
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
6 changed files with 8 additions and 8 deletions

View file

@ -74,17 +74,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers
#region Update LastMatch
LastMatch? lastMatch = await this.database.LastMatches.Where(l => l.UserId == user.UserId).FirstOrDefaultAsync();
LastContact? lastMatch = await this.database.LastContacts.Where(l => l.UserId == user.UserId).FirstOrDefaultAsync();
// below makes it not look like trash
// ReSharper disable once ConvertIfStatementToNullCoalescingExpression
if (lastMatch == null)
{
lastMatch = new LastMatch
lastMatch = new LastContact
{
UserId = user.UserId,
};
this.database.LastMatches.Add(lastMatch);
this.database.LastContacts.Add(lastMatch);
}
lastMatch.Timestamp = TimestampHelper.Timestamp;

View file

@ -27,7 +27,7 @@ namespace LBPUnion.ProjectLighthouse
public DbSet<Score> Scores { get; set; }
public DbSet<PhotoSubject> PhotoSubjects { get; set; }
public DbSet<Photo> Photos { get; set; }
public DbSet<LastMatch> LastMatches { get; set; }
public DbSet<LastContact> LastContacts { get; set; }
public DbSet<VisitedLevel> VisitedLevels { get; set; }
public DbSet<RatedLevel> RatedLevels { get; set; }
public DbSet<AuthenticationAttempt> AuthenticationAttempts { get; set; }

View file

@ -8,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
{
private static readonly Database database = new();
public static async Task<int> RecentMatches() => await database.LastMatches.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).CountAsync();
public static async Task<int> RecentMatches() => await database.LastContacts.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).CountAsync();
public static async Task<int> SlotCount() => await database.Slots.CountAsync();

View file

@ -27,7 +27,7 @@ namespace LBPUnion.ProjectLighthouse.Pages
this.PlayersOnlineCount = await StatisticsHelper.RecentMatches();
List<int> userIds = await this.Database.LastMatches.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).Select(l => l.UserId).ToListAsync();
List<int> userIds = await this.Database.LastContacts.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).Select(l => l.UserId).ToListAsync();
this.PlayersOnline = await this.Database.Users.Where(u => userIds.Contains(u.UserId)).ToListAsync();
return this.Page();

View file

@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations;
namespace LBPUnion.ProjectLighthouse.Types.Profiles
{
public class LastMatch
public class LastContact
{
[Key]
public int UserId { get; set; }

View file

@ -109,7 +109,7 @@ namespace LBPUnion.ProjectLighthouse.Types
public string Status {
get {
using Database database = new();
LastMatch? lastMatch = database.LastMatches.Where
LastContact? lastMatch = database.LastContacts.Where
(l => l.UserId == this.UserId)
.FirstOrDefault(l => TimestampHelper.Timestamp - l.Timestamp < 300);