From e06624794339cad1b35159a38f1ffc4cc056fcf0 Mon Sep 17 00:00:00 2001 From: GZTime Date: Sat, 31 Aug 2024 15:39:40 +0800 Subject: [PATCH] fix: wrong key --- src/GZCTF/Repositories/GameRepository.cs | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/GZCTF/Repositories/GameRepository.cs b/src/GZCTF/Repositories/GameRepository.cs index aacfa4b2b..eb4333cb8 100644 --- a/src/GZCTF/Repositories/GameRepository.cs +++ b/src/GZCTF/Repositories/GameRepository.cs @@ -305,7 +305,7 @@ public async Task GenScoreboard(Game game, CancellationToken to item.Rank = currentRank++; if (item.Rank <= 10) - orgTeams["all"].Add(item.Id); + orgTeams["all"].Add(item.ParticipantId); if (item.Organization is null) continue; @@ -314,32 +314,35 @@ public async Task GenScoreboard(Game game, CancellationToken to { item.OrganizationRank = rank + 1; ranks[item.Organization]++; - orgTeams[item.Organization].Add(item.Id); + orgTeams[item.Organization].Add(item.ParticipantId); } else { item.OrganizationRank = 1; ranks[item.Organization] = 1; - orgTeams[item.Organization] = [item.Id]; + orgTeams[item.Organization] = [item.ParticipantId]; } } // 7. generate top timelines by solved challenges var timelines = orgTeams.ToDictionary( i => i.Key, - i => i.Value.Select(id => - new TopTimeLine + i => i.Value.Select(pid => { - Id = id, - Name = items[id].Name, - Items = items[id].SolvedChallenges - .OrderBy(c => c.SubmitTimeUtc) - .Aggregate(new List(), (acc, c) => - { - var last = acc.LastOrDefault(); - acc.Add(new TimeLine { Score = (last?.Score ?? 0) + c.Score, Time = c.SubmitTimeUtc }); - return acc; - }) + var item = items[pid]; + return new TopTimeLine + { + Id = item.Id, + Name = item.Name, + Items = item.SolvedChallenges + .OrderBy(c => c.SubmitTimeUtc) + .Aggregate(new List(), (acc, c) => + { + var last = acc.LastOrDefault(); + acc.Add(new TimeLine { Score = (last?.Score ?? 0) + c.Score, Time = c.SubmitTimeUtc }); + return acc; + }) + }; } ) );