|
|
@ -24,7 +24,6 @@ let db = syzoj.db; |
|
|
|
|
|
|
|
|
|
|
|
let User = syzoj.model('user'); |
|
|
|
let User = syzoj.model('user'); |
|
|
|
let Problem = syzoj.model('problem'); |
|
|
|
let Problem = syzoj.model('problem'); |
|
|
|
let Contest = syzoj.model('contest'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let model = db.define('contest_player', { |
|
|
|
let model = db.define('contest_player', { |
|
|
|
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, |
|
|
|
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, |
|
|
@ -64,18 +63,96 @@ class ContestPlayer extends Model { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async loadRelationships() { |
|
|
|
async loadRelationships() { |
|
|
|
|
|
|
|
let Contest = syzoj.model('contest'); |
|
|
|
this.user = await User.fromID(this.user_id); |
|
|
|
this.user = await User.fromID(this.user_id); |
|
|
|
this.contest = await Contest.fromID(this.contest_id); |
|
|
|
this.contest = await Contest.fromID(this.contest_id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async updateScore(judge_state) { |
|
|
|
async updateScore(judge_state) { |
|
|
|
this.score_details[judge_state.problem_id] = { |
|
|
|
await this.loadRelationships(); |
|
|
|
score: judge_state.score, |
|
|
|
if (this.contest.type === 'ioi') { |
|
|
|
judge_id: judge_state.id |
|
|
|
if (!this.score_details[judge_state.problem_id]) { |
|
|
|
}; |
|
|
|
this.score_details[judge_state.problem_id] = { |
|
|
|
this.score = 0; |
|
|
|
score: judge_state.score, |
|
|
|
for (let x in this.score_details) { |
|
|
|
judge_id: judge_state.id, |
|
|
|
this.score += this.score_details[x].score; |
|
|
|
submissions: {} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].submissions[judge_state.id] = { |
|
|
|
|
|
|
|
judge_id: judge_state.id, |
|
|
|
|
|
|
|
score: judge_state.score, |
|
|
|
|
|
|
|
time: judge_state.submit_time |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let arr = Object.values(this.score_details[judge_state.problem_id].submissions); |
|
|
|
|
|
|
|
arr.sort((a, b) => a.time - b.time); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let maxScoreSubmission = null; |
|
|
|
|
|
|
|
for (let x of arr) { |
|
|
|
|
|
|
|
if (!maxScoreSubmission || x.score >= maxScoreSubmission.score && maxScoreSubmission.score < 100) { |
|
|
|
|
|
|
|
maxScoreSubmission = x; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].judge_id = maxScoreSubmission.judge_id; |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].score = maxScoreSubmission.score; |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].time = maxScoreSubmission.time; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score = 0; |
|
|
|
|
|
|
|
for (let x in this.score_details) { |
|
|
|
|
|
|
|
this.score += this.score_details[x].score; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (this.contest.type === 'noi') { |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id] = { |
|
|
|
|
|
|
|
score: judge_state.score, |
|
|
|
|
|
|
|
judge_id: judge_state.id |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.score = 0; |
|
|
|
|
|
|
|
for (let x in this.score_details) { |
|
|
|
|
|
|
|
this.score += this.score_details[x].score; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (this.contest.type === 'acm') { |
|
|
|
|
|
|
|
if (!this.score_details[judge_state.problem_id]) { |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id] = { |
|
|
|
|
|
|
|
accepted: false, |
|
|
|
|
|
|
|
unacceptedCount: 0, |
|
|
|
|
|
|
|
acceptedTime: 0, |
|
|
|
|
|
|
|
judge_id: 0, |
|
|
|
|
|
|
|
submissions: {} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].submissions[judge_state.id] = { |
|
|
|
|
|
|
|
judge_id: judge_state.id, |
|
|
|
|
|
|
|
accepted: judge_state.status === 'Accepted', |
|
|
|
|
|
|
|
time: judge_state.submit_time |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let arr = Object.values(this.score_details[judge_state.problem_id].submissions); |
|
|
|
|
|
|
|
arr.sort((a, b) => a.time - b.time); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].unacceptedCount = 0; |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].judge_id = 0; |
|
|
|
|
|
|
|
for (let x of arr) { |
|
|
|
|
|
|
|
if (x.accepted) { |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].accepted = true; |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].acceptedTime = x.time; |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].judge_id = x.judge_id; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].unacceptedCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.score_details[judge_state.problem_id].accepted) { |
|
|
|
|
|
|
|
this.score_details[judge_state.problem_id].judge_id = arr[arr.length - 1].judge_id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.score = 0; |
|
|
|
|
|
|
|
for (let x in this.score_details) { |
|
|
|
|
|
|
|
if (this.score_details[x].accepted) this.score++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|