Skip to content

Commit

Permalink
fix(Contest): return invalid when problem not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
luoingly committed Dec 11, 2024
1 parent d3a3c43 commit 6b8472b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion controllers/contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,26 @@ const findOne = async (ctx) => {
const procedure = list.map((pid, index) => {
return Problem.findOne({ pid }).lean().exec()
.then((problem) => {
overview[index] = only(problem, 'title pid')
if (!problem) {
overview[index] = { pid, invalid: true }
return Promise.resolve()
}
overview[index] = only(problem, 'pid title')
})
.then(() => {
if (overview[index].invalid) return 0
return Solution.count({ pid, mid: cid }).lean().exec()
})
.then((count) => {
if (overview[index].invalid) return
overview[index].submit = count
})
.then(() => {
if (overview[index].invalid) return 0
return Solution.count({ pid, mid: cid, judge: config.judge.Accepted }).lean().exec()
})
.then((count) => {
if (overview[index].invalid) return
overview[index].solve = count
})
})
Expand Down

0 comments on commit 6b8472b

Please sign in to comment.