Browse Source

Update.

pull/6/head
t123yh 7 years ago
parent
commit
a37e819925
  1. 3
      models/judge_state.js
  2. 19
      modules/api_v2.js

3
models/judge_state.js

@ -40,6 +40,9 @@ let model = db.define('judge_state', {
pending: { type: Sequelize.BOOLEAN }, pending: { type: Sequelize.BOOLEAN },
max_memory: { type: Sequelize.INTEGER }, max_memory: { type: Sequelize.INTEGER },
// For NOI contest
compilation: { type: Sequelize.TEXT('medium'), json: true },
result: { type: Sequelize.TEXT('medium'), json: true }, result: { type: Sequelize.TEXT('medium'), json: true },
user_id: { type: Sequelize.INTEGER }, user_id: { type: Sequelize.INTEGER },

19
modules/api_v2.js

@ -155,11 +155,28 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
} }
}); });
app.apiRouter.post('/api/v2/judge/update2', async (req, res) => { app.apiRouter.post('/api/v2/judge/compiled', 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' });
const data = req.body; const data = req.body;
let JudgeState = syzoj.model('judge_state');
let judge_state = await JudgeState.fromID(req.body.taskId);
judge_state.compilation = req.body.result;
await judge_state.save();
res.send({ return: 0 });
} catch (e) {
syzoj.log(e);
res.status(500).send(e);
}
});
app.apiRouter.post('/api/v2/judge/finished', async (req, res) => {
try {
if (req.get('Token') !== syzoj.config.judge_token) return res.status(403).send({ err: 'Incorrect token' });
let data = req.body;
let JudgeState = syzoj.model('judge_state'); let JudgeState = syzoj.model('judge_state');
let judge_state = await JudgeState.fromID(req.body.taskId); let judge_state = await JudgeState.fromID(req.body.taskId);
// await judge_state.updateResult(JSON.parse(req.body)); // await judge_state.updateResult(JSON.parse(req.body));

Loading…
Cancel
Save