Browse Source

Remove old code.

pull/6/head
t123yh 7 years ago
parent
commit
92e6eaa73a
  1. 12
      models/judge_state.js
  2. 24
      modules/api_v2.js

12
models/judge_state.js

@ -161,18 +161,6 @@ class JudgeState extends Model {
} }
} }
async updateResult(result) {
this.score = result.score;
this.pending = result.pending;
this.status = result.status;
if (this.language) {
// language is empty if it's a submit-answer problem
this.total_time = result.total_time;
this.max_memory = result.max_memory;
}
this.result = result;
}
async updateRelatedInfo(newSubmission) { async updateRelatedInfo(newSubmission) {
await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'problem', this.problem_id], async () => { await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'problem', this.problem_id], async () => {
await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'user', this.user_id], async () => { await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'user', this.user_id], async () => {

24
modules/api_v2.js

@ -155,30 +155,6 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
} }
}); });
app.apiRouter.post('/api/v2/judge/update/:id', async (req, res) => {
try {
if (req.query.session_id !== syzoj.config.judge_token) return res.status(404).send({ err: 'Permission denied' });
if (req.body.type === 'custom-test') {
let CustomTest = syzoj.model('custom_test');
let custom_test = CustomTest.fromID(req.params.id);
await custom_test.updateResult(JSON.parse(req.body.result));
await custom_test.save();
} else if (req.body.type === 'submission') {
let JudgeState = syzoj.model('judge_state');
let judge_state = await JudgeState.fromID(req.params.id);
await judge_state.updateResult(JSON.parse(req.body.result));
await judge_state.save();
await judge_state.updateRelatedInfo();
}
res.send({ return: 0 });
} catch (e) {
syzoj.log(e);
res.status(500).send(e);
}
});
app.apiRouter.post('/api/v2/judge/update2', async (req, res) => { app.apiRouter.post('/api/v2/judge/update2', async (req, res) => {
try { try {
if (req.get('Token') !== syzoj.config.judge_token) return res.status(403).send({ err: 'Incorrect token' }); if (req.get('Token') !== syzoj.config.judge_token) return res.status(403).send({ err: 'Incorrect token' });

Loading…
Cancel
Save