Browse Source

Update.

master
t123yh 7 years ago
parent
commit
a37e819925
  1. 39
      models/judge_state.js
  2. 19
      modules/api_v2.js

39
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 },
@ -55,23 +58,23 @@ let model = db.define('judge_state', {
type: { type: Sequelize.INTEGER }, type: { type: Sequelize.INTEGER },
type_info: { type: Sequelize.INTEGER } type_info: { type: Sequelize.INTEGER }
}, { }, {
timestamps: false, timestamps: false,
tableName: 'judge_state', tableName: 'judge_state',
indexes: [ indexes: [
{ {
fields: ['status'], fields: ['status'],
}, },
{ {
fields: ['score'], fields: ['score'],
}, },
{ {
fields: ['user_id'], fields: ['user_id'],
}, },
{ {
fields: ['problem_id'], fields: ['problem_id'],
} }
] ]
}); });
let Model = require('./common'); let Model = require('./common');
class JudgeState extends Model { class JudgeState extends Model {
@ -200,7 +203,7 @@ class JudgeState extends Model {
this.max_memory = 0; this.max_memory = 0;
} }
this.pending = true; this.pending = true;
this.result = { }; this.result = {};
await this.save(); await this.save();
/* /*

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