Skip to content

Commit

Permalink
Merge pull request #107 from Boost-Coder/feature/scoreRank-#106
Browse files Browse the repository at this point in the history
역량의 점수와 유저의 닉네임 같이 반환 하도록 수정
  • Loading branch information
koomin1227 authored Jun 11, 2024
2 parents 82c2992 + 6661897 commit 1704bf7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
32 changes: 31 additions & 1 deletion src/stat/dto/rank-find.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,40 @@ export class RankFindDto {
@ApiProperty()
grade: number;

constructor(total, algorithm, github, grade) {
@ApiProperty()
totalScore: number;

@ApiProperty()
algorithmScore: number;

@ApiProperty()
githubScore: number;

@ApiProperty()
gradeScore: number;

@ApiProperty()
nickname: string;

constructor(
total,
algorithm,
github,
grade,
totalScore,
algorithmScore,
githubScore,
gradeScore,
nickname,
) {
this.total = total;
this.algorithm = algorithm;
this.github = github;
this.grade = grade;
this.totalScore = totalScore;
this.algorithmScore = algorithmScore;
this.githubScore = githubScore;
this.gradeScore = gradeScore;
this.nickname = nickname;
}
}
21 changes: 19 additions & 2 deletions src/stat/rank.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
import {
BadRequestException,
Controller,
Get,
Param,
Query,
UseGuards,
} from '@nestjs/common';
import { JwtAuthGuard } from '../auth/guard/jwt-auth.guard';
import { AlgorithmService } from './service/algorithm.service';
import { RankListDto, RankListOptionDto } from './dto/rank-list-option.dto';
Expand Down Expand Up @@ -155,33 +162,43 @@ export class RankController {
const user = await this.userService.findUserByUserId(userId);

if (options.major && user.major !== options.major) {
return new RankFindDto(null, null, null, null);
throw new BadRequestException();
} else {
const algorithmRank =
await this.algorithmService.getIndividualAlgorithmRank(
userId,
options,
);
const algorithm = await this.algorithmService.findAlgorithm(userId);

const githubRank = await this.githubService.getIndividualGithubRank(
userId,
options,
);
const github = await this.githubService.findGithub(userId);

const gradeRank = await this.gradeService.getIndividualGradeRank(
userId,
options,
);
const grade = await this.gradeService.findGrade(userId);

const totalRank = await this.totalService.getIndividualTotalRank(
userId,
options,
);
const total = await this.totalService.findStat(userId);

return new RankFindDto(
totalRank ? totalRank.rank : null,
algorithmRank ? algorithmRank.rank : null,
githubRank ? githubRank.rank : null,
gradeRank ? gradeRank.rank : null,
total ? total.totalPoint : null,
algorithm ? algorithm.score : null,
github ? github.score : null,
grade ? grade.score : null,
user.nickname,
);
}
}
Expand Down

0 comments on commit 1704bf7

Please sign in to comment.