Skip to content

Commit

Permalink
Merge branch 'master' into new-table-names
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 16, 2023
2 parents c6dd2e9 + eebfdbd commit e44774b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 50 deletions.
30 changes: 6 additions & 24 deletions osu.ElasticIndexer/Score.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,18 @@ public class Score : ElasticModel
[Keyword]
public int ruleset_id { get; set; }

[Date(Format = "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss")]
public DateTimeOffset created_at { get; set; }

[Date(Format = "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss")]
public DateTimeOffset updated_at { get; set; }

[JsonIgnore]
[Ignore]
public string data
{
set => scoreData = JsonConvert.DeserializeObject<ScoreData>(value)!;
}

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

[Computed]
[Boolean]
[JsonIgnore]
public bool convert => ruleset_id != playmode;

[Computed]
[Boolean]
public bool passed => scoreData.Passed;

[Ignore]
public int playmode { get; set; }

Expand All @@ -85,7 +71,11 @@ public string data

[Computed]
[Number(NumberType.Integer)]
public int total_score => scoreData.LegacyTotalScore ?? (int)scoreData.TotalScore; // scoreData.TotalScore should never exceed int.MaxValue at the point of storage.
public int total_score => (int)scoreData.TotalScore; // scoreData.TotalScore should never exceed int.MaxValue at the point of storage.

[Computed]
[Number(NumberType.Integer)]
public int legacy_total_score => scoreData.LegacyTotalScore ?? 0;

[Computed]
[Number(NumberType.Float)]
Expand All @@ -102,14 +92,6 @@ public string data
[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.StartedAt;

[Computed]
[Date(Format = "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss")]
public DateTimeOffset? ended_at => scoreData.EndedAt;

[Computed]
[Keyword]
public List<string> mods => scoreData.Mods.Select(mod => mod.Acronym).ToList();
Expand All @@ -120,7 +102,7 @@ public string data

[Computed]
[Boolean]
public bool is_legacy => build_id == null;
public bool is_legacy => scoreData.BuildID == null;

public ScoreData scoreData = new ScoreData();

Expand Down
30 changes: 4 additions & 26 deletions osu.ElasticIndexer/schemas/scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,21 @@
"beatmap_id": {
"type": "keyword"
},
"build_id": {
"type": "keyword"
},
"convert": {
"type": "boolean"
},
"country_code": {
"type": "keyword"
},
"created_at": {
"format": "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss",
"type": "date"
},
"ended_at": {
"format": "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss",
"type": "date"
},
"id": {
"type": "long"
},
"is_legacy": {
"type": "boolean"
},
"max_combo": {
"type": "integer"
},
"mods": {
"type": "keyword"
},
"passed": {
"type": "boolean"
},
"pp": {
"type": "float"
},
Expand All @@ -52,16 +35,11 @@
"ruleset_id": {
"type": "keyword"
},
"started_at": {
"format": "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss",
"type": "date"
},
"total_score": {
"type": "integer"
},
"updated_at": {
"format": "strict_date_optional_time||epoch_millis||yyyy-MM-dd HH:mm:ss",
"type": "date"
"legacy_total_score": {
"type": "integer"
},
"user_id": {
"type": "keyword"
Expand All @@ -73,8 +51,8 @@
"number_of_shards": "2",
"number_of_replicas": "0",
"sort": {
"field": ["is_legacy", "ruleset_id", "beatmap_id", "total_score", "id"],
"order": ["asc", "asc", "asc", "desc", "asc"]
"field": ["is_legacy", "ruleset_id", "beatmap_id"],
"order": ["asc", "asc", "asc"]
}
}
}
Expand Down

0 comments on commit e44774b

Please sign in to comment.