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