Passed
Pull Request — master (#70)
by Mathieu
02:27
created

server/src/Infrastructure/Billing/Repository/QuoteRepository.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 24
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
A QuoteRepository.save 0 3 1
A QuoteRepository.countByYear 0 6 1
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