|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
const { getCachedJudgeState } = require('./judger'); |
|
|
|
|
const {getCachedJudgeState} = require('./judger'); |
|
|
|
|
const _ = require('lodash'); |
|
|
|
|
|
|
|
|
|
const getSubmissionInfo = (s, displayConfig) => ({ |
|
|
|
|
submissionId: s.id, |
|
|
|
@ -13,6 +14,12 @@ const getSubmissionInfo = (s, displayConfig) => ({
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const getRoughResult = (x, displayConfig, roughOnly) => { |
|
|
|
|
let max = 0; |
|
|
|
|
_.forEach(x.result.judge.subtasks, function (item) { |
|
|
|
|
_.forEach(item.cases, function (one) { |
|
|
|
|
max = Math.max(max, one.result.time); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
if (displayConfig.showResult) { |
|
|
|
|
if (x.pending) { |
|
|
|
|
let res = getCachedJudgeState(x.task_id) || null; |
|
|
|
@ -22,6 +29,7 @@ const getRoughResult = (x, displayConfig, roughOnly) => {
|
|
|
|
|
return Object.assign({}, res, { |
|
|
|
|
result: 'Judging', |
|
|
|
|
time: 0, |
|
|
|
|
maxItemTime: 0, |
|
|
|
|
memory: 0, |
|
|
|
|
score: 0 |
|
|
|
|
}); |
|
|
|
@ -30,6 +38,7 @@ const getRoughResult = (x, displayConfig, roughOnly) => {
|
|
|
|
|
return { |
|
|
|
|
result: x.status, |
|
|
|
|
time: displayConfig.showUsage ? x.total_time : null, |
|
|
|
|
maxItemTime: displayConfig.showUsage ? max : null, |
|
|
|
|
memory: displayConfig.showUsage ? x.max_memory : null, |
|
|
|
|
score: displayConfig.showScore ? x.score : null |
|
|
|
|
}; |
|
|
|
@ -37,14 +46,14 @@ const getRoughResult = (x, displayConfig, roughOnly) => {
|
|
|
|
|
} else { |
|
|
|
|
// 0: Waiting 1: Running
|
|
|
|
|
if (x.status === "System Error") |
|
|
|
|
return { result: "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" }; |
|
|
|
|
return {result: "Submitted"}; |
|
|
|
|
} else { |
|
|
|
|
return { result: "Compile Error" }; |
|
|
|
|
return {result: "Compile Error"}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -85,4 +94,4 @@ const processOverallResult = (source, config) => {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
module.exports = { getRoughResult, getSubmissionInfo, processOverallResult }; |
|
|
|
|
module.exports = {getRoughResult, getSubmissionInfo, processOverallResult}; |
|
|
|
|