Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SoloScoreInfo model from osu.Game #125

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions osu.ElasticIndexer/SoloScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Dapper.Contrib.Extensions;
using Nest;
using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;

namespace osu.ElasticIndexer
{
Expand Down Expand Up @@ -57,18 +58,12 @@ public class SoloScore : ElasticModel
public string data
{
get => JsonConvert.SerializeObject(scoreData);
set
{
var obj = JsonConvert.DeserializeObject<SoloScoreData>(value);

if (obj != null)
scoreData = obj;
}
set => scoreData = JsonConvert.DeserializeObject<SoloScoreInfo>(value)!;
}

[Computed]
[Keyword]
public int? build_id => scoreData.build_id;
public int? build_id => scoreData.BuildID;

[Computed]
[Boolean]
Expand All @@ -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; }
Expand All @@ -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<string> mods
{
get
{
List<dynamic> modObjects = scoreData.mods?.ToObject<List<dynamic>>() ?? new List<dynamic>();
return modObjects.Select(mod => (string)mod["acronym"]).ToList();
}
}
public List<string> 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}";
}
Expand Down
37 changes: 0 additions & 37 deletions osu.ElasticIndexer/SoloScoreData.cs

This file was deleted.

5 changes: 5 additions & 0 deletions osu.ElasticIndexer/osu.ElasticIndexer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<PackageReference Include="MySqlConnector" Version="2.1.8" />
<PackageReference Include="NEST" Version="7.17.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Game" Version="2022.821.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2022.821.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2022.821.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2022.821.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2022.821.0" />
<PackageReference Include="ppy.osu.Server.OsuQueueProcessor" Version="2022.812.0" />
</ItemGroup>
<ItemGroup>
Expand Down