1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Fix many shortcomings and compatibility issues with EF classes post-rename

This commit is contained in:
Dean Herbert 2021-12-15 00:31:35 +09:00
parent d7fe3584cd
commit 8d943b5709
10 changed files with 32 additions and 25 deletions

View File

@ -15,6 +15,8 @@ namespace osu.Game.Beatmaps
public int BeatmapSetInfoID { get; set; }
public EFBeatmapSetInfo BeatmapSetInfo { get; set; }
public int FileInfoID { get; set; }
public FileInfo FileInfo { get; set; }
@ -22,6 +24,6 @@ namespace osu.Game.Beatmaps
[Required]
public string Filename { get; set; }
public IFileInfo File => FileInfo;
IFileInfo INamedFileUsage.File => FileInfo;
}
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.ComponentModel.DataAnnotations.Schema;
using osu.Game.Database;
namespace osu.Game.Beatmaps
{
[Table(@"BeatmapDifficulty")]
public class EFBeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
{
/// <summary>

View File

@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapInfo")]
public class EFBeatmapInfo : IEquatable<EFBeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
{
public int ID { get; set; }
@ -124,7 +125,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// Currently only populated for beatmap deletion. Use <see cref="ScoreManager"/> to query scores.
/// </summary>
public List<ScoreInfo> Scores { get; set; }
public List<EFScoreInfo> Scores { get; set; }
[JsonIgnore]
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarRating);

View File

@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapMetadata")]
public class EFBeatmapMetadata : IEquatable<EFBeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
{
public int ID { get; set; }

View File

@ -14,6 +14,8 @@ using osu.Game.Extensions;
namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapSetInfo")]
public class EFBeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<EFBeatmapSetInfo>, IBeatmapSetInfo
{
public int ID { get; set; }

View File

@ -147,7 +147,7 @@ namespace osu.Game.Database
modelBuilder.Entity<EFBeatmapInfo>().HasOne(b => b.BaseDifficulty);
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
modelBuilder.Entity<EFScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
}
private class OsuDbLoggerFactory : ILoggerFactory

View File

@ -10,6 +10,7 @@ using osu.Framework.Testing;
namespace osu.Game.Rulesets
{
[ExcludeFromDynamicCompile]
[Table(@"RulesetInfo")]
public sealed class EFRulesetInfo : IEquatable<EFRulesetInfo>, IRulesetInfo
{
public int? ID { get; set; }

View File

@ -19,6 +19,7 @@ using osu.Game.Utils;
namespace osu.Game.Scoring
{
[Table(@"ScoreInfo")]
public class EFScoreInfo : IScoreInfo, IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<EFScoreInfo>, IDeepCloneable<EFScoreInfo>
{
public int ID { get; set; }
@ -45,7 +46,7 @@ namespace osu.Game.Scoring
[NotMapped]
public bool Passed { get; set; } = true;
public RulesetInfo Ruleset { get; set; }
public EFRulesetInfo Ruleset { get; set; }
private APIMod[] localAPIMods;
@ -135,9 +136,17 @@ namespace osu.Game.Scoring
public int BeatmapInfoID { get; set; }
[Column("Beatmap")]
public BeatmapInfo BeatmapInfo { get; set; }
public EFBeatmapInfo BeatmapInfo { get; set; }
public long? OnlineScoreID { get; set; }
private long? onlineID;
[JsonProperty("id")]
[Column("OnlineScoreID")]
public long? OnlineID
{
get => onlineID;
set => onlineID = value > 0 ? value : null;
}
public DateTimeOffset Date { get; set; }
@ -232,24 +241,18 @@ namespace osu.Game.Scoring
public bool Equals(EFScoreInfo other)
{
if (other == null)
return false;
if (ReferenceEquals(this, other)) return true;
if (other == null) return false;
if (ID != 0 && other.ID != 0)
return ID == other.ID;
if (OnlineScoreID.HasValue && other.OnlineScoreID.HasValue)
return OnlineScoreID == other.OnlineScoreID;
if (!string.IsNullOrEmpty(Hash) && !string.IsNullOrEmpty(other.Hash))
return Hash == other.Hash;
return ReferenceEquals(this, other);
return false;
}
#region Implementation of IHasOnlineID
public long OnlineID => OnlineScoreID ?? -1;
long IHasOnlineID<long>.OnlineID => OnlineID ?? -1;
#endregion

View File

@ -13,6 +13,10 @@ namespace osu.Game.Scoring
public bool IsManaged => ID > 0;
public int ScoreInfoID { get; set; }
public EFScoreInfo ScoreInfo { get; set; }
public int FileInfoID { get; set; }
public FileInfo FileInfo { get; set; }

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Localisation;
@ -215,14 +214,6 @@ namespace osu.Game.Scoring
}
}
// Used for database serialisation/deserialisation.
[Column("Mods")]
public string ModsJson
{
get => JsonConvert.SerializeObject(APIMods);
set => APIMods = JsonConvert.DeserializeObject<APIMod[]>(value) ?? Array.Empty<APIMod>();
}
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
{
foreach (var r in Ruleset.CreateInstance().GetHitResults())