Skip to content

Commit

Permalink
优化排行榜进度显示性能
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartHypercube committed Nov 1, 2023
1 parent 73ffa48 commit 9d9a194
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions frontend/templates/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,37 @@ <h1>{{ filters.category?`${filters.category} 类`:'' }}{{ filters.group?groups[f
if (!this.show_progress || this.user_progress) {
return;
}
this.user_progress = {};
this.objs.forEach(obj => {
axios.post('/admin/submission/', {method: 'get_user_progress', args: {user: obj.user}})
.then(({data: {value}}) => {
Vue.set(this.user_progress, obj.user, value);
});
});
axios.get('/data/core.json')
.then(({data}) => {
const challenge_flag_count = {};
for (const challenge of data.challenges) {
challenge_flag_count[challenge.id] = challenge.flags.length;
}
const user_progress = {};
for (const user of data.users) {
user_progress[user.id] = {
flags: [],
challenges: [],
};
}
const user_challenge_flag_count = {};
for (const submission of data.submissions) {
user_progress[submission.user].flags.push({
challenge: submission.challenge,
flag: submission.flag,
time: submission.time,
});
const k = `${submission.user},${submission.challenge}`;
user_challenge_flag_count[k] = (user_challenge_flag_count[k] || 0) + 1;
if (user_challenge_flag_count[k] === challenge_flag_count[submission.challenge]) {
user_progress[submission.user].challenges.push({
challenge: submission.challenge,
time: submission.time,
});
}
}
this.user_progress = user_progress;
});
},
display_time(o) {
if (o) {
Expand Down

0 comments on commit 9d9a194

Please sign in to comment.