Skip to content

Commit 2b4b80c

Browse files
committed
fix: lint
1 parent 10dac56 commit 2b4b80c

File tree

3 files changed

+53
-26
lines changed

3 files changed

+53
-26
lines changed

src/api/scorecard/scorecard.controller.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class ScorecardController {
8181
async editScorecard(
8282
@Param('id') id: string,
8383
@Body() body: ScorecardWithGroupResponseDto,
84-
): Promise<ScorecardWithGroupResponseDto> {
84+
): Promise<ScorecardWithGroupResponseDto> {
8585
return await this.scorecardService.editScorecard(id, body);
8686
}
8787

@@ -125,7 +125,9 @@ export class ScorecardController {
125125
type: ScorecardWithGroupResponseDto,
126126
})
127127
@ApiResponse({ status: 404, description: 'Scorecard not found.' })
128-
async viewScorecard(@Param('id') id: string): Promise<ScorecardWithGroupResponseDto> {
128+
async viewScorecard(
129+
@Param('id') id: string,
130+
): Promise<ScorecardWithGroupResponseDto> {
129131
return await this.scorecardService.viewScorecard(id);
130132
}
131133

@@ -184,15 +186,15 @@ export class ScorecardController {
184186
@Query('perPage') perPage: number = 10,
185187
): Promise<ScorecardPaginatedResponseDto> {
186188
const challengeTrackArray = Array.isArray(challengeTrack)
187-
? challengeTrack
188-
: challengeTrack
189-
? [challengeTrack]
190-
: [];
189+
? challengeTrack
190+
: challengeTrack
191+
? [challengeTrack]
192+
: [];
191193
const challengeTypeArray = Array.isArray(challengeType)
192-
? challengeType
193-
: challengeType
194-
? [challengeType]
195-
: [];
194+
? challengeType
195+
: challengeType
196+
? [challengeType]
197+
: [];
196198
const result = await this.scorecardService.getScoreCards({
197199
challengeTrack: challengeTrackArray,
198200
challengeType: challengeTypeArray,

src/api/scorecard/scorecard.service.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
import { Injectable, InternalServerErrorException, NotFoundException } from "@nestjs/common";
2-
import { Prisma } from "@prisma/client";
3-
import { mapScorecardRequestToDto, ScorecardPaginatedResponseDto, ScorecardQueryDto, ScorecardRequestDto, ScorecardResponseDto, ScorecardWithGroupResponseDto } from "src/dto/scorecard.dto";
4-
import { PrismaService } from "src/shared/modules/global/prisma.service";
1+
import {
2+
Injectable,
3+
InternalServerErrorException,
4+
NotFoundException,
5+
} from '@nestjs/common';
6+
import { Prisma } from '@prisma/client';
7+
import {
8+
mapScorecardRequestToDto,
9+
ScorecardPaginatedResponseDto,
10+
ScorecardQueryDto,
11+
ScorecardRequestDto,
12+
ScorecardResponseDto,
13+
ScorecardWithGroupResponseDto,
14+
} from 'src/dto/scorecard.dto';
15+
import { PrismaService } from 'src/shared/modules/global/prisma.service';
516

617
@Injectable()
718
export class ScoreCardService {
8-
constructor(
9-
private readonly prisma: PrismaService,
10-
) {}
19+
constructor(private readonly prisma: PrismaService) {}
1120

1221
/**
1322
* Adds score card
1423
* @param body body from request
1524
* @returns ScorecardWithGroupResponseDto
1625
*/
17-
async addScorecard(body: ScorecardRequestDto): Promise<ScorecardWithGroupResponseDto> {
26+
async addScorecard(
27+
body: ScorecardRequestDto,
28+
): Promise<ScorecardWithGroupResponseDto> {
1829
const data = await this.prisma.scorecard.create({
1930
data: mapScorecardRequestToDto(body),
2031
include: {
@@ -38,7 +49,10 @@ export class ScoreCardService {
3849
* @param body body from request
3950
* @returns ScorecardWithGroupResponseDto
4051
*/
41-
async editScorecard(id: string, body: ScorecardWithGroupResponseDto): Promise<ScorecardWithGroupResponseDto> {
52+
async editScorecard(
53+
id: string,
54+
body: ScorecardWithGroupResponseDto,
55+
): Promise<ScorecardWithGroupResponseDto> {
4256
const data = await this.prisma.scorecard
4357
.update({
4458
where: { id },
@@ -126,9 +140,15 @@ export class ScoreCardService {
126140
* @returns response dto
127141
*/
128142
async getScoreCards(
129-
query: ScorecardQueryDto
143+
query: ScorecardQueryDto,
130144
): Promise<ScorecardPaginatedResponseDto> {
131-
const { page = 1, perPage = 10, challengeTrack, challengeType, name } = query;
145+
const {
146+
page = 1,
147+
perPage = 10,
148+
challengeTrack,
149+
challengeType,
150+
name,
151+
} = query;
132152
const skip = (page - 1) * perPage;
133153
const where: Prisma.scorecardWhereInput = {
134154
...(challengeTrack?.length && {
@@ -161,9 +181,9 @@ export class ScoreCardService {
161181
total: totalCount,
162182
page,
163183
perPage,
164-
totalPages: Math.ceil(totalCount/perPage),
184+
totalPages: Math.ceil(totalCount / perPage),
165185
},
166186
scoreCards: data as ScorecardResponseDto[],
167187
};
168188
}
169-
}
189+
}

src/interceptors/PaginationHeaderInterceptor.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from "@nestjs/common";
2-
import { Observable, tap } from "rxjs";
3-
import { Response } from "express";
1+
import {
2+
CallHandler,
3+
ExecutionContext,
4+
Injectable,
5+
NestInterceptor,
6+
} from '@nestjs/common';
7+
import { Observable, tap } from 'rxjs';
8+
import { Response } from 'express';
49

510
@Injectable()
611
export class PaginationHeaderInterceptor implements NestInterceptor {

0 commit comments

Comments
 (0)