Browse Source

增加最大单项耗时的显示

pull/6/head
richie 5 years ago
parent
commit
3657f0d7a0
  1. 155
      libs/submissions_process.js
  2. 1
      views/submission.ejs
  3. 3
      views/submissions_item.ejs

155
libs/submissions_process.js

@ -1,88 +1,97 @@
const { getCachedJudgeState } = require('./judger'); const {getCachedJudgeState} = require('./judger');
const _ = require('lodash');
const getSubmissionInfo = (s, displayConfig) => ({ const getSubmissionInfo = (s, displayConfig) => ({
submissionId: s.id, submissionId: s.id,
taskId: s.task_id, taskId: s.task_id,
user: s.user.username, user: s.user.username,
userId: s.user_id, userId: s.user_id,
problemName: s.problem.title, problemName: s.problem.title,
problemId: s.problem_id, problemId: s.problem_id,
language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null, language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null,
codeSize: displayConfig.showCode ? s.code_length : null, codeSize: displayConfig.showCode ? s.code_length : null,
submitTime: syzoj.utils.formatDate(s.submit_time), submitTime: syzoj.utils.formatDate(s.submit_time),
}); });
const getRoughResult = (x, displayConfig, roughOnly) => { const getRoughResult = (x, displayConfig, roughOnly) => {
if (displayConfig.showResult) { let max = 0;
if (x.pending) { _.forEach(x.result.judge.subtasks, function (item) {
let res = getCachedJudgeState(x.task_id) || null; _.forEach(item.cases, function (one) {
if (!res) return null; max = Math.max(max, one.result.time);
});
});
if (displayConfig.showResult) {
if (x.pending) {
let res = getCachedJudgeState(x.task_id) || null;
if (!res) return null;
if (roughOnly) { if (roughOnly) {
return Object.assign({}, res, { return Object.assign({}, res, {
result: 'Judging', result: 'Judging',
time: 0, time: 0,
memory: 0, maxItemTime: 0,
score: 0 memory: 0,
}); score: 0
} else return res; });
} else { } else return res;
return {
result: x.status,
time: displayConfig.showUsage ? x.total_time : null,
memory: displayConfig.showUsage ? x.max_memory : null,
score: displayConfig.showScore ? x.score : null
};
}
} else { } else {
// 0: Waiting 1: Running return {
if (x.status === "System Error") result: x.status,
return { result: "System Error" }; time: displayConfig.showUsage ? x.total_time : null,
if (x.compilation == null || [0, 1].includes(x.compilation.status)) { maxItemTime: displayConfig.showUsage ? max : null,
return null; memory: displayConfig.showUsage ? x.max_memory : null,
} else { score: displayConfig.showScore ? x.score : null
if (x.compilation.status === 2) { // 2 is TaskStatus.Done };
return { result: "Submitted" };
} else {
return { result: "Compile Error" };
}
}
} }
} else {
// 0: Waiting 1: Running
if (x.status === "System Error")
return {result: "System Error"};
if (x.compilation == null || [0, 1].includes(x.compilation.status)) {
return null;
} else {
if (x.compilation.status === 2) { // 2 is TaskStatus.Done
return {result: "Submitted"};
} else {
return {result: "Compile Error"};
}
}
}
} }
const processOverallResult = (source, config) => { const processOverallResult = (source, config) => {
if (source == null) if (source == null)
return null; return null;
if (source.error != null) { if (source.error != null) {
return {
error: source.error,
systemMessage: source.systemMessage
};
}
return { return {
compile: source.compile, error: source.error,
judge: config.showDetailResult ? (source.judge && { systemMessage: source.systemMessage
subtasks: source.judge.subtasks && source.judge.subtasks.map(st => ({
score: st.score,
cases: st.cases.map(cs => ({
status: cs.status,
errorMessage: cs.errorMessage,
result: cs.result && {
type: cs.result.type,
time: config.showUsage ? cs.result.time : undefined,
memory: config.showUsage ? cs.result.memory : undefined,
scoringRate: cs.result.scoringRate,
systemMessage: cs.result.systemMessage,
input: config.showTestdata ? cs.result.input : undefined,
output: config.showTestdata ? cs.result.output : undefined,
userOutput: config.showTestdata ? cs.result.userOutput : undefined,
userError: config.showTestdata ? cs.result.userError : undefined,
spjMessage: config.showTestdata ? cs.result.spjMessage : undefined,
}
}))
}))
}) : null
}; };
}
return {
compile: source.compile,
judge: config.showDetailResult ? (source.judge && {
subtasks: source.judge.subtasks && source.judge.subtasks.map(st => ({
score: st.score,
cases: st.cases.map(cs => ({
status: cs.status,
errorMessage: cs.errorMessage,
result: cs.result && {
type: cs.result.type,
time: config.showUsage ? cs.result.time : undefined,
memory: config.showUsage ? cs.result.memory : undefined,
scoringRate: cs.result.scoringRate,
systemMessage: cs.result.systemMessage,
input: config.showTestdata ? cs.result.input : undefined,
output: config.showTestdata ? cs.result.output : undefined,
userOutput: config.showTestdata ? cs.result.userOutput : undefined,
userError: config.showTestdata ? cs.result.userError : undefined,
spjMessage: config.showTestdata ? cs.result.spjMessage : undefined,
}
}))
}))
}) : null
};
} }
module.exports = { getRoughResult, getSubmissionInfo, processOverallResult }; module.exports = {getRoughResult, getSubmissionInfo, processOverallResult};

1
views/submission.ejs

@ -39,6 +39,7 @@
<th>状态</th> <th>状态</th>
<th v-if="displayConfig.showScore">分数</th> <th v-if="displayConfig.showScore">分数</th>
<th v-if="displayConfig.showUsage">总时间</th> <th v-if="displayConfig.showUsage">总时间</th>
<th v-if="displayConfig.showUsage">最大单项时间</th>
<th v-if="displayConfig.showUsage">内存</th> <th v-if="displayConfig.showUsage">内存</th>
<th v-if="displayConfig.showCode">代码 / 答案文件</th> <th v-if="displayConfig.showCode">代码 / 答案文件</th>
<th>提交者</th> <th>提交者</th>

3
views/submissions_item.ejs

@ -88,6 +88,8 @@
<% } %> <% } %>
<td v-if="config.showUsage">{{ (data.result.time || 0).toString() + ' ms' }}</td> <td v-if="config.showUsage">{{ (data.result.time || 0).toString() + ' ms' }}</td>
<td v-if="config.showUsage">{{ (data.result.maxItemTime || 0).toString() + ' ms' }}</td>
<% if (active === 'submissions') { %> <% if (active === 'submissions') { %>
<td v-if="config.showUsage">{{ formatSize(data.result.memory * 1024, 2) }}</td> <td v-if="config.showUsage">{{ formatSize(data.result.memory * 1024, 2) }}</td>
<% } else { %> <% } else { %>
@ -177,6 +179,7 @@
} }
$('#modal-rejudge').modal('show'); $('#modal-rejudge').modal('show');
} }
function check_share() { function check_share() {
$('#modal-share').modal('show'); $('#modal-share').modal('show');
} }

Loading…
Cancel
Save