Completed
Push — master ( 7091cf...748fd1 )
by Mathieu
34s queued 24s
created

DoesLeaveExistForPeriod   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 14
dl 0
loc 15
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A isSatisfiedBy 0 9 1
1
import { Inject } from '@nestjs/common';
2
import { IEventRepository } from '../Repository/IEventRepository';
3
import { User } from 'src/Domain/HumanResource/User/User.entity';
4
import { ILeaveRepository } from 'src/Domain/HumanResource/Leave/Repository/ILeaveRepository';
5
6
export class DoesLeaveExistForPeriod {
7
  constructor(
8
    @Inject('ILeaveRepository')
9
    private readonly leaveRepository: ILeaveRepository
10
  ) {}
11
12
  public async isSatisfiedBy(
13
    user: User,
14
    startDate: string,
15
    endDate: string
16
  ): Promise<boolean> {
17
    const leaves = await this.leaveRepository.countLeavesByUserAndPeriod(user, startDate, endDate)
18
19
    return leaves > 0;
20
  }
21
}
22