| Conditions | 2 |
| Total Lines | 27 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
| 18 | |||
| 19 | public async execute({}: GetOnLeaveUsersQuery): Promise<Array<OnLeaveUserView>> { |
||
| 20 | const onLeaveUserViews: OnLeaveUserView[] = []; |
||
| 21 | |||
| 22 | const date = this.dateUtils.getCurrentDate(); |
||
| 23 | const day = date.getDate(); |
||
| 24 | const month = date.getMonth() + 1; |
||
| 25 | const year = date.getFullYear(); |
||
| 26 | |||
| 27 | const leaves = await this.leaveRepository.findLeavesForDate(year + '-' + month + '-' + day); |
||
| 28 | |||
| 29 | for (const leave of leaves) { |
||
| 30 | const user = leave.getLeaveRequest().getUser(); |
||
| 31 | |||
| 32 | onLeaveUserViews.push( |
||
| 33 | new OnLeaveUserView( |
||
| 34 | leave.getId(), |
||
| 35 | new UserSummaryView( |
||
| 36 | user.getId(), |
||
| 37 | user.getFirstName(), |
||
| 38 | user.getLastName() |
||
| 39 | ) |
||
| 40 | ) |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | return onLeaveUserViews; |
||
| 45 | } |
||
| 47 |