1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-18 06:27:18 +08:00

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
commit 0c75245806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
/// 15 2022-07-13 Added LastPlayed to BeatmapInfo.
/// 16 2022-07-15 Removed HasReplay from ScoreInfo.
/// 17 2022-07-16 Added CountryCode to RealmUser.
/// </summary>
private const int schema_version = 16;
private const int schema_version = 17;
/// <summary>
/// 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.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using osu.Game.Database;
using osu.Game.Users;
@ -17,6 +15,16 @@ namespace osu.Game.Models
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 Equals(RealmUser other)

View File

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

View File

@ -84,7 +84,7 @@ namespace osu.Game.Scoring
api.Perform(userRequest);
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
{
Username = RealmUser.Username,
Id = RealmUser.OnlineID,
Username = RealmUser.Username,
CountryCode = RealmUser.CountryCode,
};
set
{
@ -95,7 +96,8 @@ namespace osu.Game.Scoring
RealmUser = new RealmUser
{
OnlineID = user.OnlineID,
Username = user.Username
Username = user.Username,
CountryCode = user.CountryCode,
};
}
}
@ -135,6 +137,7 @@ namespace osu.Game.Scoring
{
OnlineID = RealmUser.OnlineID,
Username = RealmUser.Username,
CountryCode = RealmUser.CountryCode,
};
return clone;

View File

@ -96,7 +96,7 @@ namespace osu.Game.Skinning
new SkinInfo
{
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; }
CountryCode CountryCode { get; }
bool IsBot { get; }
bool IEquatable<IUser>.Equals(IUser? other)