Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 33 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {InjectRepository} from '@nestjs/typeorm'; |
||
2 | import {Repository} from 'typeorm'; |
||
3 | import {IDailyRateRepository} from 'src/Domain/Billing/Repository/IDailyRateRepository'; |
||
4 | import {DailyRate} from 'src/Domain/Billing/DailyRate.entity'; |
||
5 | import {User} from 'src/Domain/User/User.entity'; |
||
6 | import {Customer} from 'src/Domain/Customer/Customer.entity'; |
||
7 | import {Task} from 'src/Domain/Task/Task.entity'; |
||
8 | |||
9 | export class DailyRateRepository implements IDailyRateRepository { |
||
10 | constructor( |
||
11 | @InjectRepository(DailyRate) |
||
12 | private readonly repository: Repository<DailyRate> |
||
13 | ) {} |
||
14 | |||
15 | public save(dailyRate: DailyRate): Promise<DailyRate> { |
||
16 | return this.repository.save(dailyRate); |
||
17 | } |
||
18 | |||
19 | public findOneByUserCustomerAndTask( |
||
20 | user: User, |
||
21 | customer: Customer, |
||
22 | task: Task |
||
23 | ): Promise<DailyRate | undefined> { |
||
24 | return this.repository |
||
25 | .createQueryBuilder('dailyRate') |
||
26 | .select('dailyRate.id') |
||
27 | .where('dailyRate.user = :user', {user: user.getId()}) |
||
28 | .andWhere('dailyRate.customer = :customer', {customer: customer.getId()}) |
||
29 | .andWhere('dailyRate.task = :task', {task: task.getId()}) |
||
30 | .getOne(); |
||
31 | } |
||
32 | } |
||
33 |