|
|
@ -129,26 +129,23 @@ class Problem extends Model { |
|
|
|
this.testdata_id = file.id; |
|
|
|
this.testdata_id = file.id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getSubmitStatus(user) { |
|
|
|
async getJudgeState(user) { |
|
|
|
if (!user) return null; |
|
|
|
if (!user) return null; |
|
|
|
|
|
|
|
|
|
|
|
let JudgeState = syzoj.model('judge_state'); |
|
|
|
let JudgeState = syzoj.model('judge_state'); |
|
|
|
|
|
|
|
|
|
|
|
let status = await JudgeState.model.findAll({ |
|
|
|
let states = await JudgeState.query(null, { |
|
|
|
attributes: ['status'], |
|
|
|
|
|
|
|
where: { |
|
|
|
|
|
|
|
user_id: user.id, |
|
|
|
user_id: user.id, |
|
|
|
problem_id: this.id |
|
|
|
problem_id: this.id |
|
|
|
} |
|
|
|
}, [['submit_time', 'desc']]); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!status || status.length === 0) return null; |
|
|
|
if (!states || states.length === 0) return null; |
|
|
|
|
|
|
|
|
|
|
|
for (let x of status) { |
|
|
|
for (let x of states) { |
|
|
|
if (x.get('status') === 'Accepted') return true; |
|
|
|
if (x.status === 'Accepted') return x; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return states[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getModel() { return model; } |
|
|
|
getModel() { return model; } |
|
|
|