From 3657f0d7a014a611831787001b787a12f9cdf193 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 2 Jul 2019 16:06:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=A4=A7=E5=8D=95?= =?UTF-8?q?=E9=A1=B9=E8=80=97=E6=97=B6=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/submissions_process.js | 155 +++++++++++++++++++----------------- views/submission.ejs | 1 + views/submissions_item.ejs | 3 + 3 files changed, 86 insertions(+), 73 deletions(-) diff --git a/libs/submissions_process.js b/libs/submissions_process.js index 79f4642..6d29fc8 100644 --- a/libs/submissions_process.js +++ b/libs/submissions_process.js @@ -1,88 +1,97 @@ -const { getCachedJudgeState } = require('./judger'); +const {getCachedJudgeState} = require('./judger'); +const _ = require('lodash'); const getSubmissionInfo = (s, displayConfig) => ({ - submissionId: s.id, - taskId: s.task_id, - user: s.user.username, - userId: s.user_id, - problemName: s.problem.title, - problemId: s.problem_id, - language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null, - codeSize: displayConfig.showCode ? s.code_length : null, - submitTime: syzoj.utils.formatDate(s.submit_time), + submissionId: s.id, + taskId: s.task_id, + user: s.user.username, + userId: s.user_id, + problemName: s.problem.title, + problemId: s.problem_id, + language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null, + codeSize: displayConfig.showCode ? s.code_length : null, + submitTime: syzoj.utils.formatDate(s.submit_time), }); const getRoughResult = (x, displayConfig, roughOnly) => { - if (displayConfig.showResult) { - if (x.pending) { - let res = getCachedJudgeState(x.task_id) || null; - if (!res) return null; + 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; + if (!res) return null; - if (roughOnly) { - return Object.assign({}, res, { - result: 'Judging', - time: 0, - memory: 0, - score: 0 - }); - } else return res; - } else { - return { - result: x.status, - time: displayConfig.showUsage ? x.total_time : null, - memory: displayConfig.showUsage ? x.max_memory : null, - score: displayConfig.showScore ? x.score : null - }; - } + if (roughOnly) { + return Object.assign({}, res, { + result: 'Judging', + time: 0, + maxItemTime: 0, + memory: 0, + score: 0 + }); + } else return res; } 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" }; - } - } + 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 + }; } + } 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) => { - if (source == null) - return null; - if (source.error != null) { - return { - error: source.error, - systemMessage: source.systemMessage - }; - } + if (source == null) + return null; + if (source.error != 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 + error: source.error, + systemMessage: source.systemMessage }; + } + 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}; diff --git a/views/submission.ejs b/views/submission.ejs index 89c3eb6..3f3d23e 100644 --- a/views/submission.ejs +++ b/views/submission.ejs @@ -39,6 +39,7 @@ 状态 分数 总时间 + 最大单项时间 内存 代码 / 答案文件 提交者 diff --git a/views/submissions_item.ejs b/views/submissions_item.ejs index 5c094d1..fdd2381 100644 --- a/views/submissions_item.ejs +++ b/views/submissions_item.ejs @@ -88,6 +88,8 @@ <% } %> {{ (data.result.time || 0).toString() + ' ms' }} + {{ (data.result.maxItemTime || 0).toString() + ' ms' }} + <% if (active === 'submissions') { %> {{ formatSize(data.result.memory * 1024, 2) }} <% } else { %> @@ -177,6 +179,7 @@ } $('#modal-rejudge').modal('show'); } + function check_share() { $('#modal-share').modal('show'); }