Skip to content

Commit

Permalink
Merge branch 'main' into EW-834
Browse files Browse the repository at this point in the history
  • Loading branch information
Fshmit committed May 13, 2024
2 parents de82542 + 4087a28 commit 16793e5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
7 changes: 0 additions & 7 deletions apps/server/src/modules/copy-helper/dto/copy.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,4 @@ export class CopyApiResponse {
description: 'List of included sub elements with recursive type structure',
})
elements?: CopyApiResponse[];

@ApiPropertyOptional({
isArray: true,
enum: CopyElementType,
description: 'Array with listed types of all sub elements',
})
elementsTypes?: CopyElementType[];
}
17 changes: 1 addition & 16 deletions apps/server/src/modules/copy-helper/mapper/copy.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TaskCopyParentParams } from '@modules/task/types';
import { LessonEntity, Task } from '@shared/domain/entity';
import { EntityId } from '@shared/domain/types';
import { CopyApiResponse } from '../dto/copy.response';
import { CopyElementType, CopyStatus, CopyStatusEnum } from '../types/copy.types';
import { CopyStatus, CopyStatusEnum } from '../types/copy.types';

export class CopyMapper {
static mapToResponse(copyStatus: CopyStatus): CopyApiResponse {
Expand Down Expand Up @@ -46,19 +46,4 @@ export class CopyMapper {

return dto;
}

static mapElementsToTypes(element: CopyStatus, types: CopyElementType[] = []): CopyElementType[] {
const indexOfFound = types.indexOf(element.type);
if (indexOfFound === -1) {
types.push(element.type);
}

if (element.elements) {
element.elements.forEach((child) => {
this.mapElementsToTypes(child, types);
});
}

return types;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe('copy helper service', () => {

expect(derivedStatus).toEqual(CopyStatusEnum.FAIL);
});

it('should return fail if the last and only nested child is FAIL ', () => {
const element = createNestedStates([
CopyStatusEnum.SUCCESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class RoomsController {
): Promise<CopyApiResponse> {
const copyStatus = await this.courseCopyUc.copyCourse(currentUser.userId, urlParams.roomId);
const dto = CopyMapper.mapToResponse(copyStatus);
dto.elementsTypes = CopyMapper.mapElementsToTypes(copyStatus);
return dto;
}

Expand Down

0 comments on commit 16793e5

Please sign in to comment.