Passed
Pull Request — master (#113)
by Mathieu
11:33
created

server/src/Domain/FairCalendar/Specification/DoesEventsExistForPeriod.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

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