Privatize `UserRanks` and expose a similar `CountryRank` field instead

This commit is contained in:
Salman Ahmed 2021-02-18 15:37:52 +03:00
parent e14a59f272
commit a407bfe73b
4 changed files with 12 additions and 7 deletions

View File

@ -34,7 +34,7 @@ public class TestSceneUserProfileOverlay : OsuTestScene
Statistics = new UserStatistics
{
GlobalRank = 2148,
Ranks = new UserStatistics.UserRanks { Country = 1, },
CountryRank = 1,
PP = 4567.89m,
Level = new UserStatistics.LevelInfo
{

View File

@ -145,7 +145,7 @@ private void load(OverlayColourProvider colourProvider, TextureStore textures)
private void updateDisplay(User user)
{
hiddenDetailGlobal.Content = user?.Statistics?.GlobalRank?.ToString("\\##,##0") ?? "-";
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
hiddenDetailCountry.Content = user?.Statistics?.CountryRank?.ToString("\\##,##0") ?? "-";
}
}
}

View File

@ -177,7 +177,7 @@ private void updateDisplay(User user)
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToString("\\##,##0") ?? "-";
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToString("\\##,##0") ?? "-";
rankGraph.Statistics.Value = user?.Statistics;
}

View File

@ -29,10 +29,15 @@ public struct LevelInfo
[JsonProperty(@"global_rank")]
public int? GlobalRank;
// eventually UserRanks object will be completely replaced with separate global rank (exists) and country rank properties
// see https://github.com/ppy/osu-web/blob/cb79bb72186c8f1a25f6a6f5ef315123decb4231/app/Transformers/UserStatisticsTransformer.php#L53.
public int? CountryRank;
[JsonProperty(@"rank")]
public UserRanks Ranks;
private UserRanks ranks
{
// eventually that will also become an own json property instead of reading from a `rank` object.
// see https://github.com/ppy/osu-web/blob/cb79bb72186c8f1a25f6a6f5ef315123decb4231/app/Transformers/UserStatisticsTransformer.php#L53.
set => CountryRank = value.Country;
}
[JsonProperty(@"pp")]
public decimal? PP;
@ -115,7 +120,7 @@ public int this[ScoreRank rank]
}
}
public struct UserRanks
private struct UserRanks
{
[JsonProperty(@"country")]
public int? Country;