Skip to content

Commit

Permalink
feat(pmp-api): adding 'max lines' and 'max waiting date' property
Browse files Browse the repository at this point in the history
  • Loading branch information
va-stefanek authored and MaciejSikorski committed Mar 27, 2020
1 parent 96eb59f commit db8ae97
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export class RepositoryController {
@Post()
addRepository(@Body() addRepositoryDto: AddRepositoryDto): Promise<void> {
return this.repositoryFacade.addRepository(
new AddRepositoryCommand(addRepositoryDto.repositoryName)
new AddRepositoryCommand(
addRepositoryDto.repositoryName,
addRepositoryDto.maxLines,
addRepositoryDto.maxWaitingTime
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import { ApiProperty } from '@nestjs/swagger';
export class AddRepositoryDto {
@ApiProperty()
repositoryName: string;

@ApiProperty()
maxLines?: number;

@ApiProperty()
maxWaitingTime?: number;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export class AddRepositoryCommand {
constructor(public repositoryName: string) {}
constructor(
public repositoryName: string,
public maxLines?: number,
public maxWaitingTime?: number
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export class AddRepositoryHandler implements ICommandHandler<AddRepositoryComman
constructor(private repositoryRepository: RepositoryRepository) {}

async execute(command: AddRepositoryCommand): Promise<void> {
const repository = await this.repositoryRepository.getSingleRepositoryByName(
command.repositoryName
);
return this.repositoryRepository.save(repository).then();
const { repositoryName, maxLines, maxWaitingTime } = command;

const repository = await this.repositoryRepository.getSingleRepositoryByName(repositoryName);

repository.maxLines = maxLines;
repository.maxWaitingTime = maxWaitingTime;

return this.repositoryRepository.save(repository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export class RepositoryEntity {
@f
pictureUrl: string;

@Column({ nullable: true })
@f.optional()
maxLines?: number;

@Column({ nullable: true })
@f.optional()
maxWaitingTime?: number;

@f.array(PrEntity)
prs: PrEntity[] = [];
}

0 comments on commit db8ae97

Please sign in to comment.