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
  • add_route_assignments
  • ask-user-to-delete-exercises-on-duplicates
  • bedran_exercise-list
  • jw_sonar
  • jw_sonar_backup
  • main
  • update-dependencies
  • v6.0.0
  • 2.0.0
  • 2.1.0
  • 2.2.0
  • 3.0.0
  • 3.0.1
  • 3.1.0
  • 3.1.1
  • 3.1.2
  • 3.1.3
  • 3.2.0
  • 3.3.0
  • 3.4.0
  • 3.4.1
  • 3.4.2
  • 3.5.0
  • 3.5.1
  • 3.5.2
  • 3.5.3
  • 4.0.0
  • 4.1.0
  • 5.0.0
  • 5.0.1
  • 6.0.0-dev
  • v1.0.1
32 results

Target

Select target project
  • Dojo_Project_Nguyen/backend/dojobackendapi
  • dojo_project/projects/backend/dojobackendapi
2 results
Select Git revision
  • add_route_assignments
  • ask-user-to-delete-exercises-on-duplicates
  • bedran_exercise-list
  • jw_sonar
  • jw_sonar_backup
  • main
  • update-dependencies
  • v6.0.0
  • 2.0.0
  • 2.1.0
  • 2.2.0
  • 3.0.0
  • 3.0.1
  • 3.1.0
  • 3.1.1
  • 3.1.2
  • 3.1.3
  • 3.2.0
  • 3.3.0
  • 3.4.0
  • 3.4.1
  • 3.4.2
  • 3.5.0
  • 3.5.1
  • 3.5.2
  • 3.5.3
  • 4.0.0
  • 4.1.0
  • 5.0.0
  • 5.0.1
  • 6.0.0-dev
  • v1.0.1
32 results
Show changes
Commits on Source (9)
......@@ -17,7 +17,13 @@
- 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
- Add possibility of self-host the solution
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{
"name" : "dojo_backend_api",
"description" : "Backend API of the Dojo project",
"version" : "5.0.0",
"version" : "5.0.1",
"license" : "AGPLv3",
"author" : "Michaël Minelli <dojo@minelli.me>",
"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 {
gitlabId Int
gitlabLink String
gitlabCreationInfo Json @db.Json
gitlabCreationDate DateTime
gitlabLastInfo Json @db.Json
gitlabLastInfoDate DateTime
published Boolean @default(false)
......@@ -55,6 +56,7 @@ model Exercise {
gitlabId Int
gitlabLink String
gitlabCreationInfo Json @db.Json
gitlabCreationDate DateTime
gitlabLastInfo Json @db.Json
gitlabLastInfoDate DateTime
deleted Boolean @default(false)
......
......@@ -3,11 +3,10 @@ import '../src/init.js';
import * as process from 'process';
import SharedConfig from '../src/shared/config/SharedConfig.js';
import { UserRole } from '@prisma/client';
import { TagType, UserRole } from '@prisma/client';
import logger from '../src/shared/logging/WinstonLogger.js';
import db from '../src/helpers/DatabaseHelper.js';
import TagManager from '../src/managers/TagManager';
import { TagType } from '@prisma/client';
async function main() {
await users();
......@@ -218,6 +217,7 @@ async function assignments() {
'issue_branch_template' : null,
'autoclose_referenced_issues' : true
},
gitlabCreationDate: new Date('2021-10-14T14:20:15.239Z'),
gitlabLastInfo : {
'id' : 13862,
'description' : 'Dojo assignment repository.\n\nName of the assignment: c_hello_world',
......@@ -473,6 +473,7 @@ async function assignments() {
'issue_branch_template' : null,
'autoclose_referenced_issues' : true
},
gitlabCreationDate: new Date('2023-11-07T20:35:54.692Z'),
gitlabLastInfo : {
'id' : 13893,
'description' : 'Dojo assignment repository.\n\nName of the assignment: Technique de compilation - TP',
......@@ -766,6 +767,7 @@ async function exercises() {
'issue_branch_template' : null,
'autoclose_referenced_issues' : true
},
gitlabCreationDate: new Date('2023-12-14T14:54:35.692Z'),
gitlabLastInfo : {
'id' : 14232,
'description' : 'Dojo exercise repository based on the the assignment: Technique de compilation - TP',
......@@ -1598,7 +1600,7 @@ async function tag() {
update: {},
create: {
name: 'Java',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1606,7 +1608,7 @@ async function tag() {
update: {},
create: {
name: 'Scala',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1614,7 +1616,7 @@ async function tag() {
update: {},
create: {
name: 'Kotlin',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1622,7 +1624,7 @@ async function tag() {
update: {},
create: {
name: 'Rust',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1630,7 +1632,7 @@ async function tag() {
update: {},
create: {
name: 'JavaScript',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1638,7 +1640,7 @@ async function tag() {
update: {},
create: {
name: 'TypeScript',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1646,7 +1648,7 @@ async function tag() {
update: {},
create: {
name: 'Python',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1654,7 +1656,7 @@ async function tag() {
update: {},
create: {
name: 'HTML',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1662,7 +1664,7 @@ async function tag() {
update: {},
create: {
name: 'CSS',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1670,7 +1672,7 @@ async function tag() {
update: {},
create: {
name: 'C++',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1678,7 +1680,7 @@ async function tag() {
update: {},
create: {
name: 'Go',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1686,7 +1688,7 @@ async function tag() {
update: {},
create: {
name: 'PHP',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1694,7 +1696,7 @@ async function tag() {
update: {},
create: {
name: 'C#',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1702,7 +1704,7 @@ async function tag() {
update: {},
create: {
name: 'Swift',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1710,7 +1712,7 @@ async function tag() {
update: {},
create: {
name: 'Matlab',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1718,7 +1720,7 @@ async function tag() {
update: {},
create: {
name: 'SQL',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1726,7 +1728,7 @@ async function tag() {
update: {},
create: {
name: 'Assembly',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1734,7 +1736,7 @@ async function tag() {
update: {},
create: {
name: 'Ruby',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1742,7 +1744,7 @@ async function tag() {
update: {},
create: {
name: 'Fortran',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1750,7 +1752,7 @@ async function tag() {
update: {},
create: {
name: 'Pascal',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1758,7 +1760,7 @@ async function tag() {
update: {},
create: {
name: 'Visual Basic',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1766,7 +1768,7 @@ async function tag() {
update: {},
create: {
name: 'R',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1774,7 +1776,7 @@ async function tag() {
update: {},
create: {
name: 'Objective-C',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1782,7 +1784,7 @@ async function tag() {
update: {},
create: {
name: 'Lua',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1790,7 +1792,7 @@ async function tag() {
update: {},
create: {
name: 'Ada',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1798,7 +1800,7 @@ async function tag() {
update: {},
create: {
name: 'Haskell',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......@@ -1806,7 +1808,7 @@ async function tag() {
update: {},
create: {
name: 'Shell/PowerShell',
type : TagType.LANGUAGE,
type: TagType.LANGUAGE
}
});
await db.tag.upsert({
......
......@@ -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> {
try {
return await this.api.Projects.transfer(repoId, newRepoId);
......
......@@ -107,7 +107,8 @@ class AssignmentRoutes implements RoutesManager {
some: {
id: req.session.profile.id
}
}
},
deleted : false
},
include: {
assignment: false,
......@@ -174,6 +175,7 @@ class AssignmentRoutes implements RoutesManager {
gitlabId : repository.id,
gitlabLink : repository.web_url,
gitlabCreationInfo: repository as unknown as Prisma.JsonObject,
gitlabCreationDate: new Date(),
gitlabLastInfo : repository as unknown as Prisma.JsonObject,
gitlabLastInfoDate: new Date(),
staff : {
......
......@@ -24,6 +24,7 @@ import GlobalHelper from '../helpers/GlobalHelper.js';
import { IFileDirStat } from '../shared/helpers/recursiveFilesStats/RecursiveFilesStats.js';
import ExerciseManager from '../managers/ExerciseManager.js';
import * as Gitlab from '@gitbeaker/rest';
import { ProjectSchema } from '@gitbeaker/rest';
import GitlabTreeFileType from '../shared/types/Gitlab/GitlabTreeFileType.js';
import { GitbeakerRequestError } from '@gitbeaker/requester-utils';
......@@ -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({
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);
......@@ -225,6 +234,7 @@ class ExerciseRoutes implements RoutesManager {
gitlabId : repository.id,
gitlabLink : repository.web_url,
gitlabCreationInfo: repository as unknown as Prisma.JsonObject,
gitlabCreationDate: new Date(),
gitlabLastInfo : repository as unknown as Prisma.JsonObject,
gitlabLastInfoDate: new Date(),
members : {
......
version: '3.8'
services:
dojo-database:
container_name: dojo-database
......@@ -22,6 +21,7 @@ services:
- ADMINER_DEFAULT_SERVER=dojo-database
- 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_DESIGN=dracula
networks:
dojo-network:
aliases:
......