Corrected compilers and programs

parent 16d934fd
"use strict";
const mongoose = require('mongoose');
const logger = require('../libs/log');
const CompilerSchema = new mongoose.Schema({
name: {
......@@ -52,22 +51,19 @@ module.exports.getAll = () => {
return Compiler.find({});
};
module.exports.getMany = (ids) => {
module.exports.getMany = ids => {
return Compiler.findOne({_id: {$in: ids}});
};
module.exports.getShotForNames = (names) => {
module.exports.getShotForNames = names => {
return Compiler.find({name: {$in: names}}).select({_id: 0, name: 1, displayedName: 1, isProject: 1, extensions: 1});
};
module.exports.getCompiler = (compilerId) => {
return Compiler.findOne({_id: compilerId})
.catch(err => {
logger.error(err);
});
module.exports.get = id => {
return Compiler.findOne({_id: id})
};
module.exports.addCompiler = (name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
module.exports.add = (name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
return (new Compiler({
name: name,
displayedName: displayedName,
......@@ -77,15 +73,12 @@ module.exports.addCompiler = (name, displayedName, isProject, compileCommands, d
detectOutput: detectOutput,
runCommand: runCommand,
forcedCompileOutputExtension: forcedCompileOutputExtension
}))
.save()
.catch(err => {
logger.error(err);
});
})).save()
};
module.exports.updateCompiler = (compilerId, name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
return Compiler.findOneAndUpdate({_id: compilerId}, {
module.exports.update = (id, name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
return Compiler.findOneAndUpdate({_id: id}, {
name: name,
displayedName: displayedName,
isProject: isProject,
......@@ -95,7 +88,4 @@ module.exports.updateCompiler = (compilerId, name, displayedName, isProject, com
runCommand: runCommand,
forcedCompileOutputExtension: forcedCompileOutputExtension
})
.catch(err => {
logger.error(err);
})
};
......@@ -63,6 +63,7 @@ module.exports.connect = async (uri, options) => {
module.exports.timetables = require('./timetable');
module.exports.solutions = require('./solution');
module.exports.compilers = require('./compiler');
module.exports.programs = require('./program');
module.exports.testers = require('./tester');
} catch (error) {
......
"use strict";
const mongoose = require('mongoose');
const logger = require('../libs/log');
const ProgramSchema = new mongoose.Schema({
compiler: {
......@@ -43,39 +41,27 @@ module.exports.schema = ProgramSchema;
const Program = mongoose.connection.model('Program', ProgramSchema);
module.exports.model = Program;
module.exports.getPrograms = () => {
module.exports.getAll = () => {
return Program.find({})
.catch(err => {
logger.error(err);
});
};
module.exports.getProgram = (programId) => {
return Program.findOne({_id: programId})
.catch(err => {
logger.error(err);
});
module.exports.get = id => {
return Program.findOne({_id: id})
};
module.exports.getProgramsForOwner = (userId) => {
return Program.find({owner: userId})
.catch(err => {
logger.error(err);
});
module.exports.getForOwner = owner => {
return Program.find({owner});
};
module.exports.addProgram = (userId, displayedName, compiler, compilerArgs, file, IOType, outputFileNames) => {
module.exports.add = (owner, displayedName, compiler, compilerArgs, file, IOType, outputFileNames) => {
return (new Program({
owner: userId,
displayedName: displayedName,
compiler: compiler,
compilerArgs: compilerArgs,
file: file,
IOType: IOType,
outputFileNames: outputFileNames
}))
.save()
.catch(err => {
logger.error(err);
});
owner,
displayedName,
compiler,
compilerArgs,
file,
IOType,
outputFileNames
})).save()
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment