Skip to content

Commit

Permalink
BC-6871 - Refactor board persistence and domain model (#5030)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Uwe Ilgenstein <[email protected]>
  • Loading branch information
virgilchiriac and uidp authored Jun 14, 2024
1 parent fcff2b9 commit e50d2b4
Show file tree
Hide file tree
Showing 450 changed files with 10,482 additions and 16,312 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: npm ci
run: npm ci --prefer-offline --no-audit
- name: nest:test:cov - test all with coverage
timeout-minutes: 11
timeout-minutes: 15
run: export RUN_WITHOUT_JEST_COVERAGE='true' && export NODE_OPTIONS='--max_old_space_size=4096' && ./node_modules/.bin/jest --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage --force-exit
- name: save-coverage
run: mv coverage/lcov.info coverage/${{matrix.shard}}.info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MongoMemoryDatabaseModule } from '@infra/database';
import { MikroORM } from '@mikro-orm/core';
import { ObjectId } from '@mikro-orm/mongodb';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { createCollections } from '@shared/testing';
import { DatabaseManagementService } from './database-management.service';

const randomChars = () => new ObjectId().toHexString();
Expand All @@ -17,6 +18,9 @@ describe('DatabaseManagementService', () => {

service = module.get(DatabaseManagementService);
orm = module.get(MikroORM);

const em = module.get(EntityManager);
await createCollections(em);
});

afterAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Migration } from '@mikro-orm/migrations-mongodb';
import { BoardLayout } from '@shared/domain/domainobject';
import { BoardNodeType } from '@shared/domain/entity';
import { BoardLayout } from '@modules/board';
import { BoardNodeType } from '@modules/board/domain';

export class Migration20240415124640 extends Migration {
async up(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Migration } from '@mikro-orm/migrations-mongodb';
import { MediaBoardColors, MediaBoardLayoutType } from '@modules/board/domain';
import { MediaBoardColors, BoardLayout } from '@modules/board/domain';

export class Migration20240517135008 extends Migration {
async up(): Promise<void> {
const mediaBoards = await this.driver.nativeUpdate(
'boardnodes',
{ type: 'media-board' },
{
layout: MediaBoardLayoutType.LIST,
layout: BoardLayout.LIST,
mediaAvailableLineBackgroundColor: MediaBoardColors.TRANSPARENT,
mediaAvailableLineCollapsed: false,
}
Expand Down
31 changes: 31 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20240528140356.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20240528140356 extends Migration {
async up(): Promise<void> {
const mediaBoards = await this.driver.nativeUpdate(
'boardnodes',
{ type: 'media-board' },
{
$rename: { mediaAvailableLineBackgroundColor: 'backgroundColor', mediaAvailableLineCollapsed: 'collapsed' },
}
);

if (mediaBoards.affectedRows > 0) {
console.info(`Additional attributes added to ${mediaBoards.affectedRows} Media boards`);
}
}

async down(): Promise<void> {
const mediaBoards = await this.driver.nativeUpdate(
'boardnodes',
{ type: 'media-board' },
{
$rename: { backgroundColor: 'mediaAvailableLineBackgroundColor', collapsed: 'mediaAvailableLineCollapsed' },
}
);

if (mediaBoards.affectedRows > 0) {
console.info(`Additional attributes removed from ${mediaBoards.affectedRows} Media boards`);
}
}
}
4 changes: 2 additions & 2 deletions apps/server/src/modules/authorization/authorization.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UserRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationHelper, AuthorizationService, RuleManager } from './domain';
import {
BoardDoRule,
BoardNodeRule,
ContextExternalToolRule,
CourseGroupRule,
CourseRule,
Expand Down Expand Up @@ -35,7 +35,7 @@ import { FeathersAuthorizationService, FeathersAuthProvider } from './feathers';
RuleManager,
AuthorizationHelper,
// rules
BoardDoRule,
BoardNodeRule,
ContextExternalToolRule,
CourseGroupRule,
CourseRule,
Expand Down
Loading

0 comments on commit e50d2b4

Please sign in to comment.