Skip to content

Commit fd3765c

Browse files
committed
Fix + optimize friend leaderboards, increment level completion stat when submitting score
1 parent f4c0952 commit fd3765c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Refresh.Database/GameDatabaseContext.Leaderboard.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ public GameScore SubmitScore(ISerializedScore score, GameUser user, GameLevel le
5353
&& currentFirstPlace.Score < score.Score
5454
&& currentFirstPlace.PublisherId != user.UserId;
5555

56-
this.Write(() =>
56+
this.WriteEnsuringStatistics(level, () =>
5757
{
5858
this.GameScores.Add(newScore);
59+
level.Statistics!.CompletionCount++;
5960
});
6061

6162
this.RecalculateScoreStatistics(level.LevelId, score.ScoreType);
@@ -142,7 +143,7 @@ public DatabaseScoreList GetLevelTopScoresByFriends(GameUser user, GameLevel lev
142143
.OrderByDescending(s => s.Score)
143144
.Where(s => s.Rank != 0)
144145
//TODO: THIS CALL IS EXTREMELY INEFFECIENT!!! once we are in postgres land, figure out a way to do this effeciently
145-
.Where(s => s.PlayerIds.Any(p => mutuals.Contains(p)));
146+
.Where(s => mutuals.Contains(s.PublisherId));
146147

147148
if (scoreType != 0)
148149
scores = scores.Where(s => s.ScoreType == scoreType);

0 commit comments

Comments
 (0)