Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] records 조회에서 workouts 이름이 누락되는 문제, 로그인시 엑세스 토큰을 받고, 리프래쉬 토큰을 받을 때, 타임아웃 이 걸리는 문제 #314

Merged
merged 4 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BackEnd/src/config/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export const typeOrmConfig: TypeOrmModuleOptions = {
synchronize: false,
logging: true,
charset: 'utf8mb4',
extra: {
connectionLimit: 10,
}
};
15 changes: 7 additions & 8 deletions BackEnd/src/records/dto/record-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ApiProperty, PickType } from '@nestjs/swagger';
import { SuccessResDto } from '../../common/dto/SuccessRes.dto';
import { Record } from '../entities/records.entity';

import { Workout } from 'src/workouts/entities/workout.entity';
class WorkoutDto extends PickType(Workout, ['name']) {}
class GetRecord extends PickType(Record, [
'workout',
'profile',
'workoutTime',
'distance',
Expand All @@ -14,21 +14,20 @@ class GetRecord extends PickType(Record, [
'createdAt',
'mapCapture',
'gps'
]) {}

]) {
@ApiProperty( {type: () => WorkoutDto} )
workout: WorkoutDto;
}
class GetRecordWithId extends PickType(Record, ['id']) {}

export class CreateRecordResDto extends SuccessResDto {
@ApiProperty({ type: () => GetRecordWithId })
data: Pick<GetRecordWithId, 'id'>;
}

export class GetUsersRecordsResDto extends SuccessResDto {
@ApiProperty({ type: () => [GetRecord] })
data: GetRecord[];
}

export class GetRecordResDto extends SuccessResDto {
@ApiProperty({ type: () => GetRecord })
data: GetRecord;
}
}
2 changes: 1 addition & 1 deletion BackEnd/src/records/entities/records.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Record {
@Column({ default: false })
isPosted: boolean;

@ManyToOne(() => Profile, (profile) => profile.records) //manyToOne이 항상 외래키를 갖고 있음
@ManyToOne(() => Profile, (profile) => profile.records)
profile: Profile;

@OneToOne(() => Post, (post) => post.record)
Expand Down
15 changes: 9 additions & 6 deletions BackEnd/src/records/records.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class RecordsService {
findByDate(profileId: number, year: number, month: number, day: number) {
return this.recordsRepository
.createQueryBuilder('record')
.leftJoinAndSelect('record.workout', 'workout')
.leftJoin('record.workout', 'workout')
.addSelect('workout.name')
.where('record.profileId = :profileId', { profileId })
.andWhere(
`YEAR(record.createdAt) = :year AND MONTH(record.createdAt) = :month AND DAY(record.createdAt) = :day`,
Expand All @@ -40,11 +41,13 @@ export class RecordsService {
}

async findById(recordId: number) {
const result = await this.recordsRepository.findOne({
where: {
id: recordId,
},
});
const result = await this.recordsRepository
.createQueryBuilder('record')
.leftJoin('record.workout', 'workout')
.addSelect('workout.name')
.where('record.id = :recordId', { recordId })
.getOne();

if (!result) {
throw new NotFoundRecordException();
}
Expand Down
Loading