diff --git a/ExpressAPI/prisma/migrations/20240212153007_test_tag/migration.sql b/ExpressAPI/prisma/migrations/20240212153007_test_tag/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..1931dc55ba39c69d729213d25294057ba262c76b --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240212153007_test_tag/migration.sql @@ -0,0 +1,7 @@ +-- 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; diff --git a/ExpressAPI/prisma/migrations/20240212153538_test_tag/migration.sql b/ExpressAPI/prisma/migrations/20240212153538_test_tag/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9 --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240212153538_test_tag/migration.sql @@ -0,0 +1 @@ +-- This is an empty migration. \ No newline at end of file diff --git a/ExpressAPI/prisma/migrations/20240212155805_description_of_the_migration/migration.sql b/ExpressAPI/prisma/migrations/20240212155805_description_of_the_migration/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9 --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240212155805_description_of_the_migration/migration.sql @@ -0,0 +1 @@ +-- This is an empty migration. \ No newline at end of file diff --git a/ExpressAPI/prisma/migrations/20240212155844_description_of_the_migration/migration.sql b/ExpressAPI/prisma/migrations/20240212155844_description_of_the_migration/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..af5102c8ba20cc6051c01d3ca06b2e7f8d7e14d9 --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240212155844_description_of_the_migration/migration.sql @@ -0,0 +1 @@ +-- This is an empty migration. \ No newline at end of file diff --git a/ExpressAPI/prisma/schema.prisma b/ExpressAPI/prisma/schema.prisma index 8d0ffc7618e1a2dc1bfba227d381f3ed5d4b05fe..6fed16d63b980486c9979eb9ad1c14d9b906c6c0 100644 --- a/ExpressAPI/prisma/schema.prisma +++ b/ExpressAPI/prisma/schema.prisma @@ -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 diff --git a/ExpressAPI/src/routes/TagsRoutes.ts b/ExpressAPI/src/routes/TagsRoutes.ts index 148d7c7545ff3aa0f97b7109542b29849931cfe6..d8af7ea06e9cbf230b2bf89995c7d0a156fe503a 100644 --- a/ExpressAPI/src/routes/TagsRoutes.ts +++ b/ExpressAPI/src/routes/TagsRoutes.ts @@ -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,