Skip to content
Snippets Groups Projects
Commit f7ecffe5 authored by vincent.steinman's avatar vincent.steinman Committed by michael.minelli
Browse files

migration

parent 9c66346c
Branches
Tags
No related merge requests found
-- CreateTable
CREATE TABLE `Tag` (
`name` CHAR(36) NOT NULL,
`type` ENUM('LANGUAGE', 'FRAMEWORK', 'THEME', 'USERDEFINED') NOT NULL,
PRIMARY KEY (`name`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- This is an empty migration.
\ No newline at end of file
-- This is an empty migration.
\ No newline at end of file
-- This is an empty migration.
\ No newline at end of file
......@@ -4,7 +4,7 @@ generator client {
datasource db {
provider = "mysql"
url = env("mysql://root:9buz7f312479g6234f1gnioubervw79b8z@localhost:59231/dojo")
url = env("DATABASE_URL")
}
enum UserRole {
......@@ -13,6 +13,13 @@ enum UserRole {
ADMIN
}
enum Type{
LANGUAGE
FRAMEWORK
THEME
USERDEFINED
}
model User {
id Int @id /// The user's id is the same as their gitlab id
name String?
......@@ -75,5 +82,5 @@ model Result {
model Tag {
name String @id @db.Char(36)
type Json @db.Json
type Type
}
\ No newline at end of file
......@@ -49,39 +49,25 @@ class TagRoutes implements RoutesManager {
}
private async addTag(req: express.Request, res: express.Response) {
let name = req.body.name
let type = req.body.type
//TODO this
db.exercise.upsert({
where : { id: name },
update: {},
create: {
id : name,
type : type,
}
}
)
}
private async deleteTag(req: express.Request, res: express.Response) {
}
private async getSubmittedTag(req: express.Request, res: express.Response) {
const repoTree: Array<GitlabTreeFile> = await GitlabManager.getRepositoryTree(req.boundParams.exercise!.assignment.gitlabId);
let assignmentHjsonFile!: GitlabFile;
const immutableFiles: Array<GitlabFile> = await Promise.all(Config.assignment.baseFiles.map(async (baseFile: string) => {
const file = await GitlabManager.getFile(req.boundParams.exercise!.assignment.gitlabId, baseFile);
if ( baseFile === Config.assignment.filename ) {
assignmentHjsonFile = file;
}
return file;
}));
const dojoAssignmentFile: AssignmentFile = JSON5.parse(atob(assignmentHjsonFile.content)) as AssignmentFile;
const immutablePaths = dojoAssignmentFile.immutable.map(fileDescriptor => fileDescriptor.path);
await Promise.all(repoTree.map(async gitlabTreeFile => {
if ( gitlabTreeFile.type == GitlabTreeFileType.BLOB ) {
for ( const immutablePath of immutablePaths ) {
if ( gitlabTreeFile.path.startsWith(immutablePath) ) {
immutableFiles.push(await GitlabManager.getFile(req.boundParams.exercise!.assignment.gitlabId, gitlabTreeFile.path));
break;
}
}
}
}));
return req.session.sendResponse(res, StatusCodes.OK, {
assignment : (req.boundParams.exercise as Exercise).assignment,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment