Skip to content

Commit

Permalink
fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Nov 24, 2023
1 parent 25eead8 commit 5ba5ca2
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiProperty } from '@nestjs/swagger';

export class ContextExternalToolCountPerContextResponse {
@ApiProperty()
course: number;

@ApiProperty()
boardElement: number;

constructor(props: ContextExternalToolCountPerContextResponse) {
this.course = props.course;
this.boardElement = props.boardElement;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ContextExternalToolCountPerContextResponse } from './context-external-tool-count-per-context.response';
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { ContextExternalToolType } from '../../../../context-external-tool/entity';
import { ContextExternalToolCountPerContextResponse } from '../../../../common/controller/dto';

export class ExternalToolMetadataResponse {
@ApiProperty()
schoolExternalToolCount: number;

@ApiProperty({
type: 'object',
properties: Object.fromEntries(
Object.values(ContextExternalToolType).map((key: ContextExternalToolType) => [key, { type: 'number' }])
),
})
contextExternalToolCountPerContext: Record<ContextExternalToolType, number>;
@ApiProperty()
contextExternalToolCountPerContext: ContextExternalToolCountPerContextResponse;

constructor(externalToolMetadataResponse: ExternalToolMetadataResponse) {
this.schoolExternalToolCount = externalToolMetadataResponse.schoolExternalToolCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ContextExternalToolType } from '../../context-external-tool/entity';

export class ExternalToolMetadata {
schoolExternalToolCount: number;

contextExternalToolCountPerContext: Record<string, number>;
contextExternalToolCountPerContext: Record<ContextExternalToolType, number>;

constructor(externalToolMetadata: ExternalToolMetadata) {
this.schoolExternalToolCount = externalToolMetadata.schoolExternalToolCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Injectable } from '@nestjs/common';
import { EntityId } from '@shared/domain';
import { ContextExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo';
import { ToolContextType } from '../../common/enum';
import { ToolContextMapper } from '../../common/mapper/tool-context.mapper';
import { ContextExternalToolType } from '../../context-external-tool/entity';
import { SchoolExternalTool } from '../../school-external-tool/domain';
import { ExternalToolMetadata } from '../domain';
import { ToolContextMapper } from '../../common/mapper/tool-context.mapper';

@Injectable()
export class ExternalToolMetadataService {
Expand Down Expand Up @@ -40,11 +40,11 @@ export class ExternalToolMetadataService {
);
}

const externaltoolMetadata: ExternalToolMetadata = new ExternalToolMetadata({
const externalToolMetadata: ExternalToolMetadata = new ExternalToolMetadata({
schoolExternalToolCount: schoolExternalTools.length,
contextExternalToolCountPerContext: contextExternalToolCount,
});

return externaltoolMetadata;
return externalToolMetadata;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { ApiProperty } from '@nestjs/swagger';
import { ContextExternalToolType } from '../../../context-external-tool/entity';
import { ContextExternalToolCountPerContextResponse } from '../../../common/controller/dto';

export class SchoolExternalToolMetadataResponse {
@ApiProperty({
type: 'object',
properties: Object.fromEntries(
Object.values(ContextExternalToolType).map((key: ContextExternalToolType) => [key, { type: 'number' }])
),
})
contextExternalToolCountPerContext: Record<ContextExternalToolType, number>;
@ApiProperty()
contextExternalToolCountPerContext: ContextExternalToolCountPerContextResponse;

constructor(schoolExternalToolMetadataResponse: SchoolExternalToolMetadataResponse) {
this.contextExternalToolCountPerContext = schoolExternalToolMetadataResponse.contextExternalToolCountPerContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ContextExternalToolType } from '../../context-external-tool/entity';

export class SchoolExternalToolMetadata {
contextExternalToolCountPerContext: Record<string, number>;
contextExternalToolCountPerContext: Record<ContextExternalToolType, number>;

constructor(schoolExternalToolMetadata: SchoolExternalToolMetadata) {
this.contextExternalToolCountPerContext = schoolExternalToolMetadata.contextExternalToolCountPerContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class SchoolExternalToolMetadataService {
})
);

const schoolExternaltoolMetadata: SchoolExternalToolMetadata = new SchoolExternalToolMetadata({
const schoolExternalToolMetadata: SchoolExternalToolMetadata = new SchoolExternalToolMetadata({
contextExternalToolCountPerContext: contextExternalToolCount,
});

return schoolExternaltoolMetadata;
return schoolExternalToolMetadata;
}
}

0 comments on commit 5ba5ca2

Please sign in to comment.