Passed
Pull Request — master (#148)
by Mathieu
04:04
created

server/src/Domain/HumanResource/Leave/Specification/DoesLeaveRequestExistForPeriod.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 26
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
mnd 0
bc 0
fnc 1
dl 0
loc 26
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A DoesLeaveRequestExistForPeriod.isSatisfiedBy 0 12 1
1
import {Inject} from '@nestjs/common';
2
import { User } from '../../User/User.entity';
3
import { LeaveRequest } from '../LeaveRequest.entity';
4
import { ILeaveRequestRepository } from '../Repository/ILeaveRequestRepository';
5
6
export class DoesLeaveRequestExistForPeriod {
7
  constructor(
8
    @Inject('ILeaveRequestRepository')
9
    private readonly leaveRequestRepository: ILeaveRequestRepository
10
  ) {}
11
12
  public async isSatisfiedBy(
13
    user: User,
14
    startDate: string,
15
    endDate: string
16
  ): Promise<boolean> {
17
    return (
18
      (await this.leaveRequestRepository.findExistingLeaveRequestsByUserAndPeriod(
19
        user,
20
        startDate,
21
        endDate
22
      )) instanceof LeaveRequest
23
    );
24
  }
25
}
26