Merge pull request #19139 from frenzibyte/score-country-storage

Support storing user country on databased scores
This commit is contained in:
Dean Herbert
2022-07-18 18:13:57 +09:00
committed by GitHub
7 changed files with 22 additions and 7 deletions

View File

@ -60,8 +60,9 @@ namespace osu.Game.Database
/// 14 2022-03-01 Added BeatmapUserSettings to BeatmapInfo. /// 14 2022-03-01 Added BeatmapUserSettings to BeatmapInfo.
/// 15 2022-07-13 Added LastPlayed to BeatmapInfo. /// 15 2022-07-13 Added LastPlayed to BeatmapInfo.
/// 16 2022-07-15 Removed HasReplay from ScoreInfo. /// 16 2022-07-15 Removed HasReplay from ScoreInfo.
/// 17 2022-07-16 Added CountryCode to RealmUser.
/// </summary> /// </summary>
private const int schema_version = 16; private const int schema_version = 17;
/// <summary> /// <summary>
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods. /// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Users; using osu.Game.Users;
@ -17,6 +15,16 @@ namespace osu.Game.Models
public string Username { get; set; } = string.Empty; public string Username { get; set; } = string.Empty;
[Ignored]
public CountryCode CountryCode
{
get => Enum.TryParse(CountryString, out CountryCode country) ? country : CountryCode.Unknown;
set => CountryString = value.ToString();
}
[MapTo(nameof(CountryCode))]
public string CountryString { get; set; } = default(CountryCode).ToString();
public bool IsBot => false; public bool IsBot => false;
public bool Equals(RealmUser other) public bool Equals(RealmUser other)

View File

@ -58,6 +58,7 @@ namespace osu.Game.Rulesets.Mods
public class ModCreatedUser : IUser public class ModCreatedUser : IUser
{ {
public int OnlineID => APIUser.SYSTEM_USER_ID; public int OnlineID => APIUser.SYSTEM_USER_ID;
public CountryCode CountryCode => default;
public bool IsBot => true; public bool IsBot => true;
public string Username { get; set; } = string.Empty; public string Username { get; set; } = string.Empty;

View File

@ -84,7 +84,7 @@ namespace osu.Game.Scoring
api.Perform(userRequest); api.Perform(userRequest);
if (userRequest.Response is APIUser user) if (userRequest.Response is APIUser user)
model.RealmUser.OnlineID = user.Id; model.User = user;
} }
} }
} }

View File

@ -85,8 +85,9 @@ namespace osu.Game.Scoring
{ {
get => user ??= new APIUser get => user ??= new APIUser
{ {
Username = RealmUser.Username,
Id = RealmUser.OnlineID, Id = RealmUser.OnlineID,
Username = RealmUser.Username,
CountryCode = RealmUser.CountryCode,
}; };
set set
{ {
@ -95,7 +96,8 @@ namespace osu.Game.Scoring
RealmUser = new RealmUser RealmUser = new RealmUser
{ {
OnlineID = user.OnlineID, OnlineID = user.OnlineID,
Username = user.Username Username = user.Username,
CountryCode = user.CountryCode,
}; };
} }
} }
@ -135,6 +137,7 @@ namespace osu.Game.Scoring
{ {
OnlineID = RealmUser.OnlineID, OnlineID = RealmUser.OnlineID,
Username = RealmUser.Username, Username = RealmUser.Username,
CountryCode = RealmUser.CountryCode,
}; };
return clone; return clone;

View File

@ -96,7 +96,7 @@ namespace osu.Game.Skinning
new SkinInfo new SkinInfo
{ {
Name = beatmapInfo.ToString(), Name = beatmapInfo.ToString(),
Creator = beatmapInfo.Metadata.Author.Username ?? string.Empty Creator = beatmapInfo.Metadata.Author.Username
}; };
} }
} }

View File

@ -10,6 +10,8 @@ namespace osu.Game.Users
{ {
string Username { get; } string Username { get; }
CountryCode CountryCode { get; }
bool IsBot { get; } bool IsBot { get; }
bool IEquatable<IUser>.Equals(IUser? other) bool IEquatable<IUser>.Equals(IUser? other)