mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-30 12:42:27 +00:00
Fix StatisticsHelper concurrent exception
This commit is contained in:
parent
cf5369d372
commit
eb7cda8997
9 changed files with 65 additions and 44 deletions
|
@ -206,8 +206,9 @@ public class ScoreController : ControllerBase
|
|||
// This is hella ugly but it technically assigns the proper rank to a score
|
||||
// var needed for Anonymous type returned from SELECT
|
||||
var rankedScores = this.database.Scores
|
||||
.Where(s => playerIds == null || playerIds.Contains(s.MainPlayer))
|
||||
.Where(s => s.SlotId == slotId && s.Type == type)
|
||||
.AsEnumerable()
|
||||
.Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id)))
|
||||
.OrderByDescending(s => s.Points)
|
||||
.ThenBy(s => s.ScoreId)
|
||||
.ToList()
|
||||
|
|
|
@ -182,7 +182,7 @@ public class SlotsController : ControllerBase
|
|||
|
||||
string response = Enumerable.Aggregate(slots, string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCountForGame(this.database, token.GameVersion);
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ public class SlotsController : ControllerBase
|
|||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 30));
|
||||
|
||||
string response = Enumerable.Aggregate(slots, string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
|
||||
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCount(this.database);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class SlotsController : ControllerBase
|
|||
.Take(Math.Min(pageSize, 30));
|
||||
string response = Enumerable.Aggregate(slots, string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.TeamPickCount();
|
||||
int total = await StatisticsHelper.TeamPickCount(this.database);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public class SlotsController : ControllerBase
|
|||
|
||||
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCountForGame(this.database, token.GameVersion);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ public class SlotsController : ControllerBase
|
|||
|
||||
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(token.GameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCountForGame(this.database, token.GameVersion);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ public class SlotsController : ControllerBase
|
|||
|
||||
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(token.GameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCountForGame(this.database, token.GameVersion);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ public class SlotsController : ControllerBase
|
|||
|
||||
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(token.GameVersion));
|
||||
int start = pageStart + Math.Min(pageSize, ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots);
|
||||
int total = await StatisticsHelper.SlotCount();
|
||||
int total = await StatisticsHelper.SlotCountForGame(this.database, token.GameVersion);
|
||||
|
||||
return this.Ok(generateSlotsResponse(response, start, total));
|
||||
}
|
||||
|
|
|
@ -9,15 +9,23 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/plain")]
|
||||
public class StatisticsController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly Database database;
|
||||
|
||||
public StatisticsController(Database database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("playersInPodCount")]
|
||||
[HttpGet("totalPlayerCount")]
|
||||
public async Task<IActionResult> TotalPlayerCount() => this.Ok((await StatisticsHelper.RecentMatches()).ToString()!);
|
||||
public async Task<IActionResult> TotalPlayerCount() => this.Ok((await StatisticsHelper.RecentMatches(this.database)).ToString());
|
||||
|
||||
[HttpGet("planetStats")]
|
||||
public async Task<IActionResult> PlanetStats()
|
||||
{
|
||||
int totalSlotCount = await StatisticsHelper.SlotCount();
|
||||
int mmPicksCount = await StatisticsHelper.TeamPickCount();
|
||||
int totalSlotCount = await StatisticsHelper.SlotCount(this.database);
|
||||
int mmPicksCount = await StatisticsHelper.TeamPickCount(this.database);
|
||||
|
||||
return this.Ok
|
||||
(
|
||||
|
@ -27,5 +35,5 @@ public class StatisticsController : ControllerBase
|
|||
}
|
||||
|
||||
[HttpGet("planetStats/totalLevelCount")]
|
||||
public async Task<IActionResult> TotalLevelCount() => this.Ok((await StatisticsHelper.SlotCount()).ToString());
|
||||
public async Task<IActionResult> TotalLevelCount() => this.Ok((await StatisticsHelper.SlotCount(this.database)).ToString());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue