diff --git a/compiler.js b/compiler.js index 867bee34034bf9c8785ec721ee5538b3d5610c3d..ac2bb69cfc43726f38949f07caa271beed0743bc 100644 --- a/compiler.js +++ b/compiler.js @@ -37,6 +37,18 @@ const CompilerSchema = new mongoose.Schema({ extensions: { type: [String], default: [] + }, + index: { + type: Number, + default: 0 + }, + cpuTimeLimit: { + type: Number, + default: 2 + }, + memoryLimit: { + type: String, + default: '1M' } }); @@ -51,11 +63,11 @@ const Compiler = mongoose.connection.model('Compiler', CompilerSchema); module.exports.model = Compiler; module.exports.getAll = () => { - return Compiler.find({}); + return Compiler.find({}).sort({index: 1}); }; module.exports.getMany = ids => { - return Compiler.findOne({_id: {$in: ids}}); + return Compiler.find({_id: {$in: ids}}); }; module.exports.getShotForNames = names => { @@ -63,7 +75,7 @@ module.exports.getShotForNames = names => { }; module.exports.get = id => { - return Compiler.findOne({_id: id}) + return Compiler.findOne({_id: id}); }; module.exports.add = (name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => { diff --git a/task.js b/task.js index cf76b8a3c3ff94c987e7acccfa58557b4404dfdd..676d507d8e6b4bc6a414f5f5275e12f25ef4c58f 100644 --- a/task.js +++ b/task.js @@ -84,6 +84,10 @@ const TaskSchema = new mongoose.Schema({ type: Array, default: [] }, + useLimits: { + type: Boolean, + default: false + }, cpuTimeLimit: { type: Number, default: 2 @@ -479,10 +483,11 @@ module.exports.setCompilers = (id, addCompilers, removeCompilers) => { module.exports.setCompilerConfig = (id, compiler, config) => { return Task.findOneAndUpdate({_id: id}, { - [`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit || -1, - [`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit || -1, - [`testerConfig.compilers.${compiler}.arguments`] : config.arguments || '', - [`testerConfig.compilers.${compiler}.compileProjectFileName`] : config.compileProjectFileName || '' + [`testerConfig.compilers.${compiler}.useLimits`] : config.useLimits, + [`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit, + [`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit, + [`testerConfig.compilers.${compiler}.arguments`] : config.arguments, + [`testerConfig.compilers.${compiler}.compileProjectFileName`] : config.compileProjectFileName }); };