Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Refresh.Database/GameDatabaseContext.Activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public DatabaseActivityPage GetUserRecentActivity(ActivityQueryParameters parame
List<ObjectId?> userFriends = this.GetUsersMutuals(parameters.User).Select(u => (ObjectId?)u.UserId).ToList();

query = query.Where(e =>
e.User?.UserId == parameters.User.UserId ||
e.UserId == parameters.User.UserId ||
e.StoredObjectId == parameters.User.UserId ||
favouriteUsers.Contains(e.User?.UserId) ||
favouriteUsers.Contains(e.UserId) ||
favouriteUsers.Contains(e.StoredObjectId) ||
userFriends.Contains(e.User?.UserId) ||
userFriends.Contains(e.UserId) ||
userFriends.Contains(e.StoredObjectId) ||
#if false // FIXME: double query
this.GetLevelById(e.StoredSequentialId ?? int.MaxValue)?.Publisher?.UserId == parameters.User.UserId ||
Expand Down Expand Up @@ -146,7 +146,7 @@ public DatabaseActivityPage GetRecentActivityFromUser(ActivityQueryParameters pa
Debug.Assert(parameters.User != null);

IEnumerable<Event> events = this.GetEvents(parameters)
.Where(e => e.User?.UserId == parameters.User.UserId);
.Where(e => e.UserId == parameters.User.UserId);

return GetRecentActivity(events, parameters);
}
Expand Down
8 changes: 4 additions & 4 deletions Refresh.Database/GameDatabaseContext.Comments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public GameProfileComment PostCommentToProfile(GameUser profile, GameUser author

public DatabaseList<GameProfileComment> GetProfileComments(GameUser profile, int count, int skip) =>
new(this.GameProfileCommentsIncluded
.Where(c => c.Profile == profile)
.Where(c => c.ProfileUserId == profile.UserId)
.OrderByDescending(c => c.Timestamp), skip, count);

[Pure]
public int GetTotalCommentsForProfile(GameUser profile) => this.GameProfileComments.Count(c => c.Profile == profile);

public void DeleteProfileComment(GameProfileComment comment)
{
Debug.Assert(comment.Profile != null);
comment.Profile ??= this.GetUserByObjectId(comment.ProfileUserId)!;
this.WriteEnsuringStatistics(comment.Profile, () =>
{
comment.Profile.Statistics!.CommentCount--;
Expand Down Expand Up @@ -79,15 +79,15 @@ public GameLevelComment PostCommentToLevel(GameLevel level, GameUser author, str

public DatabaseList<GameLevelComment> GetLevelComments(GameLevel level, int count, int skip) =>
new(this.GameLevelCommentsIncluded
.Where(c => c.Level == level)
.Where(c => c.LevelId == level.LevelId)
.OrderByDescending(c => c.Timestamp), skip, count);

[Pure]
public int GetTotalCommentsForLevel(GameLevel level) => this.GameLevelComments.Count(c => c.Level == level);

public void DeleteLevelComment(GameLevelComment comment)
{
Debug.Assert(comment.Level != null);
comment.Level ??= this.GetLevelById(comment.LevelId)!;
this.WriteEnsuringStatistics(comment.Level, () =>
{
comment.Level.Statistics!.CommentCount--;
Expand Down
10 changes: 5 additions & 5 deletions Refresh.Database/GameDatabaseContext.Levels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public GameLevel GetStoryLevelById(int id)

public GameLevel UpdateLevelPublisher(GameLevel level, GameUser newAuthor)
{
if (level.Publisher?.UserId == newAuthor.UserId)
if (level.PublisherUserId == newAuthor.UserId)
return level;

if (level.Publisher != null)
Expand Down Expand Up @@ -310,7 +310,7 @@ public DatabaseList<GameLevel> GetLevelsByUser(GameUser user, int count, int ski
{
levels = this.GetLevelsByGameVersion(levelFilterSettings.GameVersion)
.FilterByLevelFilterSettings(accessor, levelFilterSettings)
.Where(l => l.Publisher == null);
.Where(l => l.PublisherUserId == null);
}
else if (user.Username == SystemUsers.UnknownUserName)
{
Expand All @@ -329,7 +329,7 @@ public DatabaseList<GameLevel> GetLevelsByUser(GameUser user, int count, int ski
{
levels = this.GetLevelsByGameVersion(levelFilterSettings.GameVersion)
.FilterByLevelFilterSettings(accessor, levelFilterSettings)
.Where(l => l.Publisher == user);
.Where(l => l.PublisherUserId == user.UserId);
}

return new(levels.OrderByDescending(l => l.UpdateDate), skip, count);
Expand Down Expand Up @@ -519,11 +519,11 @@ public DatabaseList<GameLevel> SearchForLevels(int count, int skip, GameUser? us

public int GetTotalLevelsPublishedByUser(GameUser user)
=> this.GameLevels
.Count(r => r.Publisher == user);
.Count(r => r.PublisherUserId == user.UserId);

public int GetTotalLevelsPublishedByUser(GameUser user, TokenGame game)
=> this.GameLevels
.Count(r => r.Publisher == user && r.GameVersion == game);
.Count(r => r.PublisherUserId == user.UserId && r.GameVersion == game);

[Pure]
public int GetTotalTeamPickCount(TokenGame game) => this.GameLevels.FilterByGameVersion(game).Count(l => l.DateTeamPicked != null);
Expand Down
8 changes: 4 additions & 4 deletions Refresh.Database/GameDatabaseContext.Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public void ClearLoginFailNotificationsForUser(GameUser user)
{
this.Write(() =>
{
this.GameNotifications.RemoveRange(n => n.User == user && n.Title == LoginFail);
this.GameNotifications.RemoveRange(n => n.UserId == user.UserId && n.Title == LoginFail);
});
}

[Pure]
public int GetNotificationCountByUser(GameUser user) =>
this.GameNotifications
.Count(n => n.User == user);
.Count(n => n.UserId == user.UserId);

[Pure]
public DatabaseList<GameNotification> GetNotificationsByUser(GameUser user, int count, int skip)
Expand All @@ -65,13 +65,13 @@ public DatabaseList<GameNotification> GetNotificationsByUser(GameUser user, int
[Pure]
public GameNotification? GetNotificationByUuid(GameUser user, ObjectId id)
=> this.GameNotifications
.FirstOrDefault(n => n.User == user && n.NotificationId == id);
.FirstOrDefault(n => n.UserId == user.UserId && n.NotificationId == id);

public void DeleteNotificationsByUser(GameUser user)
{
this.Write(() =>
{
this.GameNotifications.RemoveRange(n => n.User == user);
this.GameNotifications.RemoveRange(n => n.UserId == user.UserId);
});
}

Expand Down
4 changes: 2 additions & 2 deletions Refresh.Database/GameDatabaseContext.Photos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public GamePhoto UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject
this.WriteEnsuringStatistics(publisher, level, () =>
{
level.Statistics!.PhotoInLevelCount++;
if (level.Publisher?.UserId == publisher.UserId)
if (level.PublisherUserId == publisher.UserId)
{
level.Statistics!.PhotoByPublisherCount++;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ public void RemovePhoto(GamePhoto photo)
this.WriteEnsuringStatistics(photo.Publisher, photo.Level, () =>
{
photo.Level.Statistics!.PhotoInLevelCount--;
if (photo.Level.Publisher?.UserId == photo.PublisherId)
if (photo.Level.PublisherUserId == photo.PublisherId)
{
photo.Level.Statistics!.PhotoByPublisherCount--;
}
Expand Down
4 changes: 2 additions & 2 deletions Refresh.Database/GameDatabaseContext.Registration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ public void VerifyUserEmail(GameUser user)
this.Write(() =>
{
user.EmailAddressVerified = true;
this.EmailVerificationCodes.RemoveRange(c => c.User == user);
this.EmailVerificationCodes.RemoveRange(c => c.UserId == user.UserId);
});
}

public bool VerificationCodeMatches(GameUser user, string code) =>
this.EmailVerificationCodes.Any(c => c.User == user && c.Code == code);
this.EmailVerificationCodes.Any(c => c.UserId == user.UserId && c.Code == code);

public bool IsVerificationCodeExpired(EmailVerificationCode code) => code.ExpiryDate < this._time.Now;

Expand Down
Loading
Loading