mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
leaderboard query fixes
This commit is contained in:
parent
af08dbf5f0
commit
57904b3b4a
@ -170,9 +170,9 @@ namespace sodoff.Services {
|
|||||||
List<UserAchievementInfo> achievementInfo = new();
|
List<UserAchievementInfo> achievementInfo = new();
|
||||||
var topAchievers = ctx.AchievementPoints.Where(x => x.Type == request.PointTypeID)
|
var topAchievers = ctx.AchievementPoints.Where(x => x.Type == request.PointTypeID)
|
||||||
.Select(e => new { e.Viking.Uid, e.Viking.Name, e.Value })
|
.Select(e => new { e.Viking.Uid, e.Viking.Name, e.Value })
|
||||||
|
.OrderByDescending(e => e.Value)
|
||||||
.Skip((request.Page - 1) * request.Quantity)
|
.Skip((request.Page - 1) * request.Quantity)
|
||||||
.Take(request.Quantity)
|
.Take(request.Quantity);
|
||||||
.OrderByDescending(e => e.Value);
|
|
||||||
|
|
||||||
foreach (var a in topAchievers) {
|
foreach (var a in topAchievers) {
|
||||||
achievementInfo.Add(new UserAchievementInfo {
|
achievementInfo.Add(new UserAchievementInfo {
|
||||||
|
@ -27,7 +27,7 @@ public class GameDataService {
|
|||||||
viking.GameData.Add(gameData);
|
viking.GameData.Add(gameData);
|
||||||
|
|
||||||
}
|
}
|
||||||
gameData.DatePlayed = DateTime.Now;
|
gameData.DatePlayed = DateTime.UtcNow;
|
||||||
SavePairs(gameData, xmlDocumentData);
|
SavePairs(gameData, xmlDocumentData);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
return true;
|
return true;
|
||||||
@ -41,16 +41,13 @@ public class GameDataService {
|
|||||||
if (startDate != null && endDate != null)
|
if (startDate != null && endDate != null)
|
||||||
query = query.Where(x => x.DatePlayed >= startDate && x.DatePlayed <= endDate.Value.AddMinutes(2));
|
query = query.Where(x => x.DatePlayed >= startDate && x.DatePlayed <= endDate.Value.AddMinutes(2));
|
||||||
|
|
||||||
selectedData = query.SelectMany(e => e.GameDataPairs)
|
var query2 = query.SelectMany(e => e.GameDataPairs)
|
||||||
.Where(x => x.Name == key)
|
.Where(x => x.Name == key);
|
||||||
.Select(e => new GameDataResponse(e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value))
|
|
||||||
.Take(count)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (AscendingOrder)
|
if (AscendingOrder)
|
||||||
selectedData.Sort((a, b) => a.Value.CompareTo(b.Value));
|
selectedData = query2.OrderBy(e => e.Value).Select(e => new GameDataResponse(e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)).Take(count).ToList();
|
||||||
else
|
else
|
||||||
selectedData.Sort((a, b) => b.Value.CompareTo(a.Value));
|
selectedData = query2.OrderByDescending(e => e.Value).Select(e => new GameDataResponse(e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)).Take(count).ToList();
|
||||||
|
|
||||||
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user