Skip to content

Commit

Permalink
fix: incorrect scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 31, 2024
1 parent 1d991fe commit 84b5105
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"@vitejs/plugin-react": "^4.3.1",
"axios": "^1.7.5",
"axios": "^1.7.6",
"babel-plugin-prismjs": "^2.1.0",
"eslint": "^9.9.1",
"eslint-plugin-oxlint": "^0.9.1",
Expand Down
12 changes: 6 additions & 6 deletions src/GZCTF/ClientApp/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions src/GZCTF/Repositories/GameRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ public Task<Game[]> GetGames(int count, int skip, CancellationToken token) =>
Context.Games.OrderByDescending(g => g.Id).Skip(skip).Take(count).ToArrayAsync(token);

public void FlushGameInfoCache() => cache.Remove(CacheKey.BasicGameInfo);

#region Generate Scoreboard


// By xfoxfu & GZTimeWalker @ 2022/04/03
// Refactored by GZTimeWalker @ 2024/08/31
public async Task<ScoreboardModel> GenScoreboard(Game game, CancellationToken token = default)
Expand Down Expand Up @@ -235,8 +233,8 @@ public async Task<ScoreboardModel> GenScoreboard(Game game, CancellationToken to
game.BloodBonus.SecondBloodFactor,
game.BloodBonus.ThirdBloodFactor
];

foreach (var item in submissions)
foreach (var item in submissions.OrderBy(s => s.SubmitTimeUtc))
{
var challenge = challenges[item.Id];
var scoreboardItem = items[item.ParticipantId];
Expand Down Expand Up @@ -307,7 +305,8 @@ public async Task<ScoreboardModel> GenScoreboard(Game game, CancellationToken to
{
item.OrganizationRank = rank + 1;
ranks[item.Organization]++;
orgTeams[item.Organization].Add(item.Id);
if (item.OrganizationRank <= 10)
orgTeams[item.Organization].Add(item.Id);
}
else
{
Expand Down Expand Up @@ -354,8 +353,6 @@ public async Task<ScoreboardModel> GenScoreboard(Game game, CancellationToken to
BloodBonusValue = game.BloodBonus.Val
};
}

#endregion Generate Scoreboard
}

public class ScoreboardCacheHandler : ICacheRequestHandler
Expand Down

0 comments on commit 84b5105

Please sign in to comment.