Passed
Pull Request — master (#75)
by Mathieu
01:46
created

GetMonthlyActivitiesAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 16
dl 0
loc 16
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A index 0 6 1
1
import {Controller, Inject, UseGuards, Query, Get} from '@nestjs/common';
2
import {AuthGuard} from '@nestjs/passport';
3
import {ApiUseTags, ApiBearerAuth, ApiOperation} from '@nestjs/swagger';
4
import {IQueryBus} from 'src/Application/IQueryBus';
5
import {GetMonthlyEventsQuery} from 'src/Application/FairCalendar/Query/GetMonthlyEventsQuery';
6
import {MonthlyEventsDTO} from './DTO/MonthlyEventsDTO';
7
8
@Controller('events')
9
@ApiUseTags('Event')
10
@ApiBearerAuth()
11
@UseGuards(AuthGuard('bearer'))
12
export class GetMonthlyActivitiesAction {
13
  constructor(
14
    @Inject('IQueryBus')
15
    private readonly queryBus: IQueryBus
16
  ) {}
17
18
  @Get()
19
  @ApiOperation({title: 'Get monthly events by user'})
20
  public async index(@Query() dto: MonthlyEventsDTO) {
21
    return await this.queryBus.execute(
22
      new GetMonthlyEventsQuery(new Date(dto.date), dto.userId)
23
    );
24
  }
25
}
26