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

Recent_Played 테이블 생성 + API 수정 #290

Merged
merged 14 commits into from
Dec 6, 2023
Merged

Conversation

khw3754
Copy link
Collaborator

@khw3754 khw3754 commented Dec 6, 2023

Issue

Overview

  • Recent_Played 테이블 생성
  • Music_Playlist 테이블 updated_at -> created_at 으로 필드명 변경
  • 모든 최근 재생 목록 관련 API들 User 모듈로 이동
  • /user/recent-played PATCH -> PUT
  • GET /user/recent-info 음악 수, 썸네일 링크 응답하는 API 구현
  • 불필요한 모듈 의존 관계 삭제

Screenshot

  • GET /users/recent-info 최근 재생 목록 정보 API
image
  • GET /users/recent-played 최근 재생 목록 노래 정보 API
image
  • PUT /users/recent-played 최근 재생 목록 노래 update
image

* 최근 재생 목록을 관리하는 recent_played entity 생성
* created_at 으로 이름 변경
* signup 에서 createRecentPlaylist 삭제
* 음악이 해당 유저의 최근 재생 목록에 있는지 확인하는 함수
* recent_played 테이블을 활용하는 방법으로 수정
* PATCH -> PUT
* Recent_Played 테이블을 활용하도록 수정
* 불필요해진 모듈 관계 삭제
* 최근 재생 목록 관련 쿼리문 추가
* 최근 재생 목록 GET API 수정
* Recent_Played 테이블 활용
* recent 관련 API 모두 USER 모듈로 이동
* recent_played 테이블을 따로 만든 것을 고려
* GET /users/recent-info 구현
* 최근 재생 목록의 music_count, thumbnail 응답
* 최근 재생 목록의 노래를 받는 쿼리에서 음악의 아티스트 정보가 없는 이슈 발견
* 유저 정보 포함하도록 수정
* updateRecentMusic 에서 노래가 없는 경우 예외 처리
@khw3754 khw3754 added ✨ feat 기능 개발 🖥 server server labels Dec 6, 2023
@khw3754 khw3754 added this to the ⏯️ playlist milestone Dec 6, 2023
@khw3754 khw3754 self-assigned this Dec 6, 2023
@khw3754 khw3754 requested a review from sk000801 as a code owner December 6, 2023 13:18
@khw3754 khw3754 linked an issue Dec 6, 2023 that may be closed by this pull request
* 엔티티 추가에 대응
Copy link
Member

@sk000801 sk000801 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래 커멘트는 제가 잘 이해했는지 묻는 질문이랑 감탄사 밖에 없습니당 👍😊
형운님 코드는 볼때마다 섬세해서 감탄하는 것 같아요. 고생 진짜 엄청 많이 하셨어요 !!

},
{
provide: getRepositoryToken(Music_Playlist),
provide: getRepositoryToken(Recent_Played),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여러 개의 모듈이 의존관계를 갖다가 Recent_Played만 딱 들어가니까 깔끔하고 좋은 것 같네요! 👍😊

@@ -88,4 +92,37 @@ export class UserController {
this.logger.log(`GET /users/search - keyword=${keyword}`);
return this.userService.getCertainKeywordNicknameUser(keyword);
}

@Put('recent-played')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 요 부분 put으로 변경하신 이유가 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그 전에는 date 한 부분만 update 하기도 하고 멱등하지 않다고 생각해서 Patch 를 썼는데
바뀐 후에는 멱등해서 Put 으로 바꿨습니다!

Comment on lines +144 to +153
if (!(await Music.getMusicById(music_id))) {
this.logger.error(
`user.service - updateRecentMusic : NOT_EXIST_MUSIC_ID`,
);
throw new CatchyException(
'NOT_EXIST_MUSIC_ID',
HTTP_STATUS_CODE.BAD_REQUEST,
ERROR_CODE.NOT_EXIST_MUSIC_ID,
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 뭔가 당연하게 생각해서 처리할 생각도 못했는 이런 에러까지 고려하신 것 엄청 세심하시네요 ! 👍😊

Comment on lines +185 to +200
async getRecentPlaylistMusicCount(user_id: string): Promise<number> {
try {
return await this.recentPlayedRepository.count({
where: { user: { user_id } },
});
} catch {
this.logger.error(
`user.service - getRecentPlaylistMusicCount : QUERY_ERROR`,
);
throw new CatchyException(
'QUERY_ERROR',
HTTP_STATUS_CODE.SERVER_ERROR,
ERROR_CODE.QUERY_ERROR,
);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이게 한 사용자의 최근 재생 목록 곡 수 반환하는거죠?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네 맞습니다!

Comment on lines +53 to +55
const userMusicData = await this.userService.getRecentPlayedMusicByUserId(
userId,
count,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이건 최근 재생목록 개수를 count로 따로 설정하게끔 하신거군요!

@sk000801
Copy link
Member

sk000801 commented Dec 6, 2023

(제가 잘 이해했는지 묻는 단순 질문입니당)
/users/recent-info 이거 사용자의 플레이리스트들 모아놓는 부분에서 필요해서 만드신 건가요 ??

@khw3754 khw3754 merged commit 518ccca into develop Dec 6, 2023
1 check passed
@khw3754 khw3754 deleted the server/feature/287 branch December 6, 2023 15:46
@khw3754
Copy link
Collaborator Author

khw3754 commented Dec 6, 2023

네네 정확합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feat 기능 개발 🖥 server server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recent_played table 생성
2 participants