Skip to content

Commit fd4d845

Browse files
committed
fix: remove findAllRotations default value
1 parent 39e358a commit fd4d845

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Diff for: src/rotation/dto/find-rotation-query.dto.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { Transform } from 'class-transformer';
33
import { IsNumber, IsOptional, Max, Min } from 'class-validator';
44

55
export class FindRotationQueryDto {
6-
private currentDate = new Date();
7-
86
@Transform((params) => +params.value)
97
@ApiProperty({
108
required: false,
@@ -15,7 +13,7 @@ export class FindRotationQueryDto {
1513
@IsNumber()
1614
@Min(1)
1715
@Max(12)
18-
month?: number = this.currentDate.getMonth() + 1;
16+
month?: number;
1917

2018
@Transform((params) => +params.value)
2119
@ApiProperty({
@@ -27,5 +25,5 @@ export class FindRotationQueryDto {
2725
@IsNumber()
2826
@Min(2020)
2927
@Max(2100)
30-
year?: number = this.currentDate.getFullYear();
28+
year?: number;
3129
}

Diff for: src/rotation/rotations.service.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,24 @@ export class RotationsService {
351351
* 기본적으로는 모든 로테이션을 반환.
352352
* 만약 parameter로 month와 year가 들어오면, 해당 스코프에 맞는 레코드를 반환.
353353
*/
354-
async findAllRotation(year: number, month: number): Promise<FindAllRotationDto[]> {
355-
const records = this.rotationRepository.find({
354+
async findAllRotation(year?: number, month?: number): Promise<FindAllRotationDto[]> {
355+
const records = await this.rotationRepository.find({
356356
where: {
357-
year: year,
358-
month: month,
357+
year,
358+
month,
359+
},
360+
relations: ['user'],
361+
select: {
362+
user: {
363+
nickname: true,
364+
},
359365
},
360366
});
361367

362-
const modifiedRecords = await Promise.all(
363-
(await records).map(async (record) => {
364-
const userRecord = await this.userService.findOneById(record.userId);
365-
return { ...record, intraId: userRecord.nickname };
366-
}),
367-
);
368+
const modifiedRecords = records.map((records) => {
369+
const { user, ...other } = records;
370+
return { ...other, intraId: user.nickname };
371+
});
368372

369373
return modifiedRecords;
370374
}

0 commit comments

Comments
 (0)