Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 24 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {InjectRepository} from '@nestjs/typeorm'; |
||
2 | import {Repository} from 'typeorm'; |
||
3 | import {IQuoteRepository} from 'src/Domain/Billing/Repository/IQuoteRepository'; |
||
4 | import {Quote} from 'src/Domain/Billing/Quote.entity'; |
||
5 | |||
6 | export class QuoteRepository implements IQuoteRepository { |
||
7 | constructor( |
||
8 | @InjectRepository(Quote) |
||
9 | private readonly repository: Repository<Quote> |
||
10 | ) {} |
||
11 | |||
12 | public save(quote: Quote): Promise<Quote> { |
||
13 | return this.repository.save(quote); |
||
14 | } |
||
15 | |||
16 | public countByYear(year: number): Promise<number> { |
||
17 | return this.repository |
||
18 | .createQueryBuilder('quote') |
||
19 | .select('quote.id') |
||
20 | .where('extract(year FROM quote.date) = :year', {year}) |
||
21 | .getCount(); |
||
22 | } |
||
23 | } |
||
24 |