Fix score leaderboard at end of levels (#190)

This commit is contained in:
Josh 2022-02-23 09:06:11 -06:00 committed by GitHub
commit 535116c2e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,7 +82,7 @@ public class ScoreController : ControllerBase
await this.database.SaveChangesAsync(); await this.database.SaveChangesAsync();
string myRanking = this.getScores(score.SlotId, score.Type, user); string myRanking = this.getScores(score.SlotId, score.Type, user, -1, 5, "scoreboardSegment");
return this.Ok(myRanking); return this.Ok(myRanking);
} }
@ -105,7 +105,7 @@ public class ScoreController : ControllerBase
} }
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
private string getScores(int slotId, int type, User user, int pageStart = -1, int pageSize = 5) private string getScores(int slotId, int type, User user, int pageStart = -1, int pageSize = 5, string rootName = "scores")
{ {
// This is hella ugly but it technically assigns the proper rank to a score // This is hella ugly but it technically assigns the proper rank to a score
// var needed for Anonymous type returned from SELECT // var needed for Anonymous type returned from SELECT
@ -138,11 +138,11 @@ public class ScoreController : ControllerBase
); );
string res; string res;
if (myScore == null) res = LbpSerializer.StringElement("scores", serializedScores); if (myScore == null) res = LbpSerializer.StringElement(rootName, serializedScores);
else else
res = LbpSerializer.TaggedStringElement res = LbpSerializer.TaggedStringElement
( (
"scores", rootName,
serializedScores, serializedScores,
new Dictionary<string, object> new Dictionary<string, object>
{ {