1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Merge pull request #20846 from peppy/reduce-solo-scores-legacy-serialisation

Avoid serialising some more properties of `SoloScoreInfo` unless present
This commit is contained in:
Dan Balasescu 2022-10-21 20:38:49 +09:00 committed by GitHub
commit bbdeec1630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,6 +114,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("has_replay")]
public bool HasReplay { get; set; }
// These properties are calculated or not relevant to any external usage.
public bool ShouldSerializeID() => false;
public bool ShouldSerializeUser() => false;
public bool ShouldSerializeBeatmap() => false;
@ -122,6 +123,18 @@ namespace osu.Game.Online.API.Requests.Responses
public bool ShouldSerializeOnlineID() => false;
public bool ShouldSerializeHasReplay() => false;
// These fields only need to be serialised if they hold values.
// Generally this is required because this model may be used by server-side components, but
// we don't want to bother sending these fields in score submission requests, for instance.
public bool ShouldSerializeEndedAt() => EndedAt != default;
public bool ShouldSerializeStartedAt() => StartedAt != default;
public bool ShouldSerializeLegacyScoreId() => LegacyScoreId != null;
public bool ShouldSerializeLegacyTotalScore() => LegacyTotalScore != null;
public bool ShouldSerializeMods() => Mods.Length > 0;
public bool ShouldSerializeUserID() => UserID > 0;
public bool ShouldSerializeBeatmapID() => BeatmapID > 0;
public bool ShouldSerializeBuildID() => BuildID != null;
#endregion
public override string ToString() => $"score_id: {ID} user_id: {UserID}";