Browse Source

WTF was written for custom test ???

pull/6/head
Menci 7 years ago
parent
commit
56f8d46f52
  1. 5
      models/waiting_judge.js
  2. 5
      modules/api_v2.js

5
models/waiting_judge.js

@ -23,6 +23,7 @@ let Sequelize = require('sequelize');
let db = syzoj.db;
let JudgeState = syzoj.model('judge_state');
let CustomTest = syzoj.model('custom_test');
let model = db.define('waiting_judge', {
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
@ -54,6 +55,10 @@ class WaitingJudge extends Model {
}, val)));
}
async getCustomTest() {
return CustomTest.fromID(this.judge_id);
}
async getJudgeState() {
return JudgeState.fromID(this.judge_id);
}

5
modules/api_v2.js

@ -92,6 +92,7 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
let judge_state, custom_test;
await syzoj.utils.lock('/api/v2/judge/peek', async () => {
let waiting_judge = await WaitingJudge.findOne({ order: [['priority', 'ASC'], ['id', 'ASC']] });
console.log(waiting_judge);
if (!waiting_judge) {
return;
}
@ -133,12 +134,12 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
});
}
} else if (custom_test) {
console.log({
res.send({
have_task: 1,
judge_id: custom_test.id,
code: custom_test.code,
language: custom_test.language,
input_file: (await require('fs-extra').readFileAsync(custom_test.input_file)).toString(),
input_file: (await require('fs-extra').readFileAsync(custom_test.input_filepath)).toString(),
time_limit: custom_test.problem.time_limit,
memory_limit: custom_test.problem.memory_limit,
file_io: custom_test.problem.file_io,

Loading…
Cancel
Save