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

refactor: 패키지 구조 정리 및 추천 알고리즘 추상화 #454

Open
wants to merge 8 commits into
base: backend
Choose a base branch
from

Conversation

0chil
Copy link
Collaborator

@0chil 0chil commented Feb 14, 2024

관련 이슈번호

작업 사항

@thdwoqor, @Songusika 가 기존에 작업해주시던 브랜치입니다.

당시에 백엔드 브랜치에 대한 충돌로 Rebase 후 별도의 브랜치에서 작업했으며,
두분이 작업해 주신 내용만 따로 임시 PR에 모아두었습니다.
'추천 알고리즘 추상화' 이전에 두 분이 작업해주시던 내용이고, UUID 관련 내용과 MemberGenre 분리에 관한 내용이 들어있네요.

따라서 현재 PR이 아닌 임시 PR에서
UUID 위주로 리뷰해주시면 될 것 같습니다. (MemberGenre의 코드 리뷰는 끝난 상태입니다)

머지 계획

refactor/441(추천 알고리즘 추상화) --- merge --> refactor/add-aggregate-2(현재) --- merge --> backend
이렇게 머지할 계획입니다.
현재 앞단계는 실행됐고, 이 브랜치도 리뷰 후에 머지할 예정입니다.

시간이 얼마나 걸릴지 몰라 콩하나 브랜치를 로컬에서 미리 머지해봤는데요,
다행히 충돌이 2개 뿐이네요! (병렬적으로 작업해도 괜찮다는 의미입니다)
image
따라서 콩하나 PR을 먼저 머지해주셔도 괜찮습니다. @kong-hana01

thdwoqor and others added 8 commits November 23, 2023 15:12
* refactor: 장르 추천 도메인 서비스 분리

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor: 가중치 값 객체화

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor: Room 추천 인터페이스 분리

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor: 추천 알고리즘 도메인 용어 반영

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor: 사용하지 않는 예외 삭제

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor(RandomRoomInGenre): override 어노테이션 명시

Co-authored-by: songusika <[email protected]>
Co-authored-by: 0chil <[email protected]>

* refactor: 랜덤 장르 추천기 이름 리뷰 반영

* refactor: Genre를 룸 패키지로 이동

* refactor: VO에 Lombok 사용

* refactor: MemberGenres 팩토리 메서드 제거

---------

Co-authored-by: 0chil <[email protected]>
Copy link
Collaborator

@kong-hana01 kong-hana01 left a comment

Choose a reason for hiding this comment

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

오우 고생 많으셨습니다 ㅎㅎ

파일 변경 수만 봐도 엄청 고생하신게 느껴지네요!

Comment on lines +5 to +8
public interface GenreRecommender {

Genre recommend(final Long memberId);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@GetMapping("/genres")
public ResponseEntity<MemberGenresResponse> showMemberDetails(@Auth final Long memberId) {
boolean hasFavorite = memberGenreService.hasFavorite(memberId);
return ResponseEntity.ok().body(new MemberGenresResponse(hasFavorite));
Copy link
Collaborator

Choose a reason for hiding this comment

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

MemberGenresResponse를 service에서 만들지 않는 이유가 있나요!?

Comment on lines +20 to +30
public MemberGenres(final List<MemberGenre> memberGenres) {
validateHasMemberGenres(memberGenres);
this.memberGenres = memberGenres;
}

public MemberGenres(final Long memberId) {
this(Arrays.stream(Genre.values())
.map(genre -> new MemberGenre(genre, memberId))
.toList()
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

하나는 초기에 생성할 때 사용하고 다른 하나는 repository에서 사용하는 거군요!

}

private MemberGenres toMemberGenres(final Long memberId) {
return new MemberGenres(memberGenreRepository.findByMemberId(memberId));
Copy link
Collaborator

Choose a reason for hiding this comment

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

return new MemberGenres(memberGenreRepository.findByMemberId(memberId));

return memberGenreRepository.getAllByMemberId(memberId);로도 작성할 수 있겠네요!

Comment on lines +34 to +39
@TransactionalEventListener
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void adjustMemberGenreWeight(final MemberGenreEvent memberGenreEvent) {
MemberGenres memberGenres = toMemberGenres(memberGenreEvent.getMemberId());
memberGenres.adjustWeight(memberGenreEvent.getGenre(), memberGenreEvent.getWeightFactor());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

이제 데드락에 유의해서 hikari cp connection도 생각해봐야겠네요 ㅋㅋㅋㅋ

Copy link
Collaborator

Choose a reason for hiding this comment

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

분리하고 보니까 아주 깔끔하네용 ㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend 백엔드 분야 refactoring
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants