Skip to content

Commit

Permalink
fix: set findBy functions
Browse files Browse the repository at this point in the history
  • Loading branch information
whiitex committed Mar 12, 2024
1 parent f0c6a4e commit 1c53702
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions api/src/recruitment-session/recruitment-session.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export class RecruitmentSessionController {
@CheckPolicies((ability) => ability.can(Action.Read, 'RecruitmentSession'))
async findActive(
@Ability() ability: AppAbility,
): Promise<RecruitmentSession> {
): Promise<RecruitmentSessionResponseDto> {
const recruitmentSession =
await this.recruitmentSessionService.findActiveRecruitmentSession();
await this.recruitmentSessionService.findActiveRecruitmentSession()[0];
if (recruitmentSession === null) {
throw new NotFoundException();
}
Expand Down Expand Up @@ -125,7 +125,7 @@ export class RecruitmentSessionController {
const recruitmentSession =
await this.recruitmentSessionService.findRecruitmentSessionById(
sessionId,
);
)[0];

if (recruitmentSession === null) throw new NotFoundException();

Expand All @@ -147,7 +147,7 @@ export class RecruitmentSessionController {
// There should be only one active recruitment session at a time
if (updateRecruitmentSession.state === RecruitmentSessionState.Active) {
const currentlyActiveRecruitmentSession =
await this.recruitmentSessionService.findActiveRecruitmentSession();
await this.recruitmentSessionService.findActiveRecruitmentSession()[0];
if (
currentlyActiveRecruitmentSession &&
currentlyActiveRecruitmentSession.id !== recruitmentSession.id // It's ok to set 'Active' to the (already) active recruitment session
Expand Down Expand Up @@ -206,7 +206,7 @@ export class RecruitmentSessionController {
const toRemove =
await this.recruitmentSessionService.findRecruitmentSessionById(
recruitmentSessionId,
);
)[0];
if (!toRemove) throw new NotFoundException('Recruitment session not found');

// Check if recruitment session has pending interviews
Expand All @@ -223,7 +223,7 @@ export class RecruitmentSessionController {

// Delete recruitment session
const deletedRecruitmentSession =
await this.recruitmentSessionService.deletRecruitmentSession(toRemove);
await this.recruitmentSessionService.deleteRecruitmentSession(toRemove);

return plainToClass(
RecruitmentSessionResponseDto,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Recruitment Session Service', () => {
jest
.spyOn(mockedRepository, 'remove')
.mockResolvedValue(mockRecruitmentSession);
const result = await recruitmentSessionService.deletRecruitmentSession(
const result = await recruitmentSessionService.deleteRecruitmentSession(
mockRecruitmentSession,
);
expect(result).toEqual(mockRecruitmentSession);
Expand Down
2 changes: 1 addition & 1 deletion api/src/recruitment-session/recruitment-session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class RecruitmentSessionService {
});
}

async deletRecruitmentSession(
async deleteRecruitmentSession(
recruitmentSession: RecruitmentSession,
): Promise<RecruitmentSession> {
return await this.recruitmentSessionRepository.remove(recruitmentSession);
Expand Down

0 comments on commit 1c53702

Please sign in to comment.