Skip to content

Commit

Permalink
Add scores to ActivityPage response
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jul 11, 2023
1 parent 8c9e082 commit c7dac96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class ApiActivityPageResponse : IApiResponse, IDataConvertableFrom<ApiAct
public required IEnumerable<ApiEventResponse> Events { get; set; }
public required IEnumerable<ApiGameUserResponse> Users { get; set; }
public required IEnumerable<ApiGameLevelResponse> Levels { get; set; }
public required IEnumerable<ApiGameScoreResponse> Scores { get; set; }

public static ApiActivityPageResponse? FromOld(ActivityPage? old)
{
Expand All @@ -18,6 +19,7 @@ public class ApiActivityPageResponse : IApiResponse, IDataConvertableFrom<ApiAct
Events = ApiEventResponse.FromOldList(old.Events),
Users = ApiGameUserResponse.FromOldList(old.Users.Users),
Levels = ApiGameLevelResponse.FromOldList(old.Levels.Items),
Scores = ApiGameScoreResponse.FromOldList(old.Scores),
};
}

Expand Down
6 changes: 6 additions & 0 deletions Refresh.GameServer/Types/Activity/ActivityPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ public class ActivityPage

[XmlElement("slots")]
public SerializedLevelList Levels { get; set; }

[XmlIgnore, JsonIgnore]
public List<GameSubmittedScore> Scores { get; set; }

public ActivityPage()
{
this.Events = new List<Event>();
this.Groups = new ActivityGroups();
this.Levels = new SerializedLevelList();
this.Users = new SerializedUserList();
this.Scores = new List<GameSubmittedScore>();
}

public ActivityPage(GameDatabaseContext database, int count = 20, int skip = 0, long timestamp = 0, long endTimestamp = 0, bool generateGroups = true, GameLevel? level = null)
Expand Down Expand Up @@ -87,6 +91,8 @@ public ActivityPage(GameDatabaseContext database, int count = 20, int skip = 0,
.Select(e => database.GetScoreByObjectId(e.StoredObjectId))
.ToList()!;

this.Scores = scores;

this.Groups = generateGroups ? this.GenerateGroups(users, scores) : new ActivityGroups();

this.Groups.Groups = this.Groups.Groups
Expand Down

0 comments on commit c7dac96

Please sign in to comment.