Browse Source

Fix submissions page problem ID filter doesn't work

pull/6/head
Menci 8 years ago
parent
commit
3f0457a562
  1. 14
      modules/submission.js

14
modules/submission.js

@ -29,7 +29,6 @@ app.get('/submissions', async (req, res) => {
let where = {};
if (user) where.user_id = user.id;
else if (req.query.submitter) where.user_id = -1;
if (req.query.problem_id) where.problem_id = parseInt(req.query.problem_id) || -1;
let minScore = parseInt(req.query.min_score);
if (isNaN(minScore)) minScore = 0;
@ -49,10 +48,21 @@ app.get('/submissions', async (req, res) => {
where.type = { $ne: 1 };
if (!res.locals.user || !await res.locals.user.hasPrivilege('manage_problem')) {
if (req.query.problem_id) {
where.problem_id = {
$and: [
{ $in: syzoj.db.literal('(SELECT `id` FROM `problem` WHERE `is_public` = 1' + (res.locals.user ? (' OR `user_id` = ' + res.locals.user.id) : '') + ')') },
{ $eq: where.problem_id = parseInt(req.query.problem_id) || -1 }
]
};
} else {
where.problem_id = {
$in: syzoj.db.literal('(SELECT `id` FROM `problem` WHERE `is_public` = 1' + (res.locals.user ? (' OR `user_id` = ' + res.locals.user.id) : '') + ')')
$in: syzoj.db.literal('(SELECT `id` FROM `problem` WHERE `is_public` = 1' + (res.locals.user ? (' OR `user_id` = ' + res.locals.user.id) : '') + ')'),
};
}
} else {
if (req.query.problem_id) where.problem_id = parseInt(req.query.problem_id) || -1;
}
let paginate = syzoj.utils.paginate(await JudgeState.count(where), req.query.page, syzoj.config.page.judge_state);
let judge_state = await JudgeState.query(paginate, where, [['submit_time', 'desc']]);

Loading…
Cancel
Save