diff --git a/osu.ElasticIndexer/SoloScore.cs b/osu.ElasticIndexer/SoloScore.cs index 2b8aa21..780b472 100644 --- a/osu.ElasticIndexer/SoloScore.cs +++ b/osu.ElasticIndexer/SoloScore.cs @@ -8,6 +8,7 @@ using Dapper.Contrib.Extensions; using Nest; using Newtonsoft.Json; +using osu.Game.Online.API.Requests.Responses; namespace osu.ElasticIndexer { @@ -57,18 +58,12 @@ public class SoloScore : ElasticModel public string data { get => JsonConvert.SerializeObject(scoreData); - set - { - var obj = JsonConvert.DeserializeObject(value); - - if (obj != null) - scoreData = obj; - } + set => scoreData = JsonConvert.DeserializeObject(value)!; } [Computed] [Keyword] - public int? build_id => scoreData.build_id; + public int? build_id => scoreData.BuildID; [Computed] [Boolean] @@ -77,7 +72,7 @@ public string data [Computed] [Boolean] - public bool passed => scoreData.passed; + public bool passed => scoreData.Passed; [Ignore] public int playmode { get; set; } @@ -89,47 +84,40 @@ public string data [Computed] [Number(NumberType.Integer)] - public int total_score => scoreData.total_score; + public int total_score => scoreData.TotalScore; [Computed] [Number(NumberType.Float)] - public double accuracy => scoreData.accuracy; + public double accuracy => scoreData.Accuracy; [Computed] [Number(NumberType.Integer)] - public int max_combo => scoreData.max_combo; + public int max_combo => scoreData.MaxCombo; [Computed] [Keyword] - public string? rank => scoreData.rank; + public string rank => scoreData.Rank.ToString(); [Ignore] public int user_warnings { get; set; } [Computed] [Date(Format = "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss")] - public DateTimeOffset? started_at => scoreData.started_at; + public DateTimeOffset? started_at => scoreData.StartedAt; [Computed] [Date(Format = "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss")] - public DateTimeOffset? ended_at => scoreData.ended_at; + public DateTimeOffset? ended_at => scoreData.EndedAt; [Computed] [Keyword] - public List mods - { - get - { - List modObjects = scoreData.mods?.ToObject>() ?? new List(); - return modObjects.Select(mod => (string)mod["acronym"]).ToList(); - } - } + public List mods => scoreData.Mods.Select(mod => mod.Acronym).ToList(); [Computed] [Keyword] public string? country_code { get; set; } - public SoloScoreData scoreData = new SoloScoreData(); + public SoloScoreInfo scoreData = new SoloScoreInfo(); public override string ToString() => $"score_id: {id} user_id: {user_id} beatmap_id: {beatmap_id} ruleset_id: {ruleset_id}"; } diff --git a/osu.ElasticIndexer/SoloScoreData.cs b/osu.ElasticIndexer/SoloScoreData.cs deleted file mode 100644 index 0e69804..0000000 --- a/osu.ElasticIndexer/SoloScoreData.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json.Linq; - -namespace osu.ElasticIndexer -{ - [SuppressMessage("ReSharper", "InconsistentNaming")] - [SuppressMessage("Style", "IDE1006")] - public class SoloScoreData - { - public int? build_id { get; set; } - - [DefaultValue(false)] - public bool passed { get; set; } - - [DefaultValue(0)] - public int total_score { get; set; } - - [DefaultValue(0d)] - public double accuracy { get; set; } - - [DefaultValue(0)] - public int max_combo { get; set; } - - public string? rank { get; set; } - - public DateTimeOffset? started_at { get; set; } - - public DateTimeOffset? ended_at { get; set; } - - public JToken? mods { get; set; } - } -} diff --git a/osu.ElasticIndexer/osu.ElasticIndexer.csproj b/osu.ElasticIndexer/osu.ElasticIndexer.csproj index 59ea2a4..e94e756 100644 --- a/osu.ElasticIndexer/osu.ElasticIndexer.csproj +++ b/osu.ElasticIndexer/osu.ElasticIndexer.csproj @@ -12,6 +12,11 @@ + + + + +