mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 05:43:33 +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:
commit
bbdeec1630
@ -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}";
|
||||
|
Loading…
Reference in New Issue
Block a user