Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • Dojo_Project_Nguyen/backend/dojobackendapi
  • dojo_project/projects/backend/dojobackendapi
2 results
Select Git revision
Show changes
Commits on Source (9)
...@@ -17,7 +17,13 @@ ...@@ -17,7 +17,13 @@
- No modifications / Keep major and minors versions in sync with all parts of the project - No modifications / Keep major and minors versions in sync with all parts of the project
--> -->
## 5.0.0 (Upcoming) ## 5.0.1 (2025-02-25)
### 🐛 Bugfix
- Fix some bugs related to assignments / exercises deletion
## 5.0.0 (2024-10-21)
### ✨ Feature ### ✨ Feature
- Add possibility of self-host the solution - Add possibility of self-host the solution
......
This diff is collapsed.
{ {
"name" : "dojo_backend_api", "name" : "dojo_backend_api",
"description" : "Backend API of the Dojo project", "description" : "Backend API of the Dojo project",
"version" : "5.0.0", "version" : "5.0.1",
"license" : "AGPLv3", "license" : "AGPLv3",
"author" : "Michaël Minelli <dojo@minelli.me>", "author" : "Michaël Minelli <dojo@minelli.me>",
"main" : "dist/src/app.js", "main" : "dist/src/app.js",
......
/*
Warnings:
- Added the required column `gitlabCreationDate` to the `Assignment` table without a default value. This is not possible if the table is not empty.
- Added the required column `gitlabCreationDate` to the `Exercise` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `Assignment` ADD COLUMN `gitlabCreationDate` DATETIME(3) NULL AFTER `gitlabCreationInfo`;
UPDATE `Assignment` SET `gitlabCreationDate` = `gitlabLastInfoDate`;
ALTER TABLE `Assignment` MODIFY COLUMN `gitlabCreationDate` DATETIME(3) NOT NULL AFTER `gitlabCreationInfo`;
-- AlterTable
ALTER TABLE `Exercise` ADD COLUMN `gitlabCreationDate` DATETIME(3) NULL DEFAULT NULL AFTER `gitlabCreationInfo`;
UPDATE `Exercise` SET `gitlabCreationDate` = `gitlabLastInfoDate`;
ALTER TABLE `Exercise` MODIFY COLUMN `gitlabCreationDate` DATETIME(3) NOT NULL AFTER `gitlabCreationInfo`;
...@@ -38,6 +38,7 @@ model Assignment { ...@@ -38,6 +38,7 @@ model Assignment {
gitlabId Int gitlabId Int
gitlabLink String gitlabLink String
gitlabCreationInfo Json @db.Json gitlabCreationInfo Json @db.Json
gitlabCreationDate DateTime
gitlabLastInfo Json @db.Json gitlabLastInfo Json @db.Json
gitlabLastInfoDate DateTime gitlabLastInfoDate DateTime
published Boolean @default(false) published Boolean @default(false)
...@@ -55,6 +56,7 @@ model Exercise { ...@@ -55,6 +56,7 @@ model Exercise {
gitlabId Int gitlabId Int
gitlabLink String gitlabLink String
gitlabCreationInfo Json @db.Json gitlabCreationInfo Json @db.Json
gitlabCreationDate DateTime
gitlabLastInfo Json @db.Json gitlabLastInfo Json @db.Json
gitlabLastInfoDate DateTime gitlabLastInfoDate DateTime
deleted Boolean @default(false) deleted Boolean @default(false)
......
This diff is collapsed.
...@@ -133,6 +133,17 @@ class GitlabManager extends SharedGitlabManager { ...@@ -133,6 +133,17 @@ class GitlabManager extends SharedGitlabManager {
} }
} }
async renameRepository(repoId: number, newName: string): Promise<ProjectSchema> {
try {
return await this.api.Projects.edit(repoId, {
name: newName
});
} catch ( e ) {
logger.error(JSON.stringify(e));
return Promise.reject(e);
}
}
async moveRepository(repoId: number, newRepoId: number): Promise<ProjectSchema> { async moveRepository(repoId: number, newRepoId: number): Promise<ProjectSchema> {
try { try {
return await this.api.Projects.transfer(repoId, newRepoId); return await this.api.Projects.transfer(repoId, newRepoId);
......
...@@ -107,7 +107,8 @@ class AssignmentRoutes implements RoutesManager { ...@@ -107,7 +107,8 @@ class AssignmentRoutes implements RoutesManager {
some: { some: {
id: req.session.profile.id id: req.session.profile.id
} }
} },
deleted : false
}, },
include: { include: {
assignment: false, assignment: false,
...@@ -174,6 +175,7 @@ class AssignmentRoutes implements RoutesManager { ...@@ -174,6 +175,7 @@ class AssignmentRoutes implements RoutesManager {
gitlabId : repository.id, gitlabId : repository.id,
gitlabLink : repository.web_url, gitlabLink : repository.web_url,
gitlabCreationInfo: repository as unknown as Prisma.JsonObject, gitlabCreationInfo: repository as unknown as Prisma.JsonObject,
gitlabCreationDate: new Date(),
gitlabLastInfo : repository as unknown as Prisma.JsonObject, gitlabLastInfo : repository as unknown as Prisma.JsonObject,
gitlabLastInfoDate: new Date(), gitlabLastInfoDate: new Date(),
staff : { staff : {
......
...@@ -24,6 +24,7 @@ import GlobalHelper from '../helpers/GlobalHelper.js'; ...@@ -24,6 +24,7 @@ import GlobalHelper from '../helpers/GlobalHelper.js';
import { IFileDirStat } from '../shared/helpers/recursiveFilesStats/RecursiveFilesStats.js'; import { IFileDirStat } from '../shared/helpers/recursiveFilesStats/RecursiveFilesStats.js';
import ExerciseManager from '../managers/ExerciseManager.js'; import ExerciseManager from '../managers/ExerciseManager.js';
import * as Gitlab from '@gitbeaker/rest'; import * as Gitlab from '@gitbeaker/rest';
import { ProjectSchema } from '@gitbeaker/rest';
import GitlabTreeFileType from '../shared/types/Gitlab/GitlabTreeFileType.js'; import GitlabTreeFileType from '../shared/types/Gitlab/GitlabTreeFileType.js';
import { GitbeakerRequestError } from '@gitbeaker/requester-utils'; import { GitbeakerRequestError } from '@gitbeaker/requester-utils';
...@@ -110,11 +111,19 @@ class ExerciseRoutes implements RoutesManager { ...@@ -110,11 +111,19 @@ class ExerciseRoutes implements RoutesManager {
} }
} }
await GitlabManager.moveRepository(repoId, Config.gitlab.group.deletedExercises); // We rename (with unique str added) the repository before moving it because of potential name conflicts
const newName: string = `${ req.boundParams.exercise!.name }_${ uuidv4() }`;
await GitlabManager.renameRepository(repoId, newName);
const repository: ProjectSchema = await GitlabManager.moveRepository(repoId, Config.gitlab.group.deletedExercises);
await db.exercise.update({ await db.exercise.update({
where: { id: req.boundParams.exercise!.id }, where: { id: req.boundParams.exercise!.id },
data : { deleted: true } data : {
name : newName,
gitlabLastInfo : repository as unknown as Prisma.JsonObject,
gitlabLastInfoDate: new Date(),
deleted : true
}
}); });
return req.session.sendResponse(res, StatusCodes.OK); return req.session.sendResponse(res, StatusCodes.OK);
...@@ -225,6 +234,7 @@ class ExerciseRoutes implements RoutesManager { ...@@ -225,6 +234,7 @@ class ExerciseRoutes implements RoutesManager {
gitlabId : repository.id, gitlabId : repository.id,
gitlabLink : repository.web_url, gitlabLink : repository.web_url,
gitlabCreationInfo: repository as unknown as Prisma.JsonObject, gitlabCreationInfo: repository as unknown as Prisma.JsonObject,
gitlabCreationDate: new Date(),
gitlabLastInfo : repository as unknown as Prisma.JsonObject, gitlabLastInfo : repository as unknown as Prisma.JsonObject,
gitlabLastInfoDate: new Date(), gitlabLastInfoDate: new Date(),
members : { members : {
......
version: '3.8'
services: services:
dojo-database: dojo-database:
container_name: dojo-database container_name: dojo-database
...@@ -22,6 +21,7 @@ services: ...@@ -22,6 +21,7 @@ services:
- ADMINER_DEFAULT_SERVER=dojo-database - ADMINER_DEFAULT_SERVER=dojo-database
- TZ=Europe/Zurich - TZ=Europe/Zurich
- ADMINER_PLUGINS=dump-alter dump-bz2 dump-date dump-json dump-xml dump-zip edit-foreign edit-textarea foreign-system json-column sql-log struct-comments tables-filter - ADMINER_PLUGINS=dump-alter dump-bz2 dump-date dump-json dump-xml dump-zip edit-foreign edit-textarea foreign-system json-column sql-log struct-comments tables-filter
- ADMINER_DESIGN=dracula
networks: networks:
dojo-network: dojo-network:
aliases: aliases:
......