mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: homework: fix penaltyRules validate
This commit is contained in:
3 files changed
+13
-2
No files matched your search
@@ -20,8 +20,15 @@ import {
|
||||
} from '../service/server';
|
||||
import { ContestCodeHandler, ContestFileDownloadHandler, ContestScoreboardHandler } from './contest';
|
||||
|
||||
const validatePenaltyRules = (input: string) => yaml.load(input);
|
||||
const convertPenaltyRules = validatePenaltyRules;
|
||||
const validatePenaltyRules = (input: string) => {
|
||||
try {
|
||||
yaml.load(input);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const convertPenaltyRules = (input: string) => yaml.load(input);
|
||||
|
||||
class HomeworkMainHandler extends Handler {
|
||||
@param('group', Types.Name, true)
|
||||
|
||||
@@ -145,6 +145,7 @@ export class ProblemModel {
|
||||
tag: string[] = [], meta: ProblemCreateOptions = {},
|
||||
) {
|
||||
const [doc] = await ProblemModel.getMulti(domainId, {})
|
||||
.withReadPreference('primary')
|
||||
.sort({ docId: -1 }).limit(1).project({ docId: 1 })
|
||||
.toArray();
|
||||
const result = await ProblemModel.addWithId(
|
||||
|
||||
@@ -550,6 +550,9 @@ export const coreScripts: MigrationScript[] = [
|
||||
}
|
||||
}
|
||||
await iterateAllProblem(['domainId', 'docId', 'tag'], async (pdoc) => {
|
||||
if (pdoc.tag && ['string', 'number'].includes(typeof pdoc.tag)) {
|
||||
return { tag: [pdoc.tag.toString().trim()].filter((i) => i) };
|
||||
}
|
||||
if (pdoc.tag?.some((i) => typeof i !== 'string')) {
|
||||
return { tag: pdoc.tag.filter((i) => i).map((i) => i.toString()) };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user