-
Notifications
You must be signed in to change notification settings - Fork 2
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
modify - 일별챌린지 결과 전송 후 챌린지의 변경된 상태값들을 반환하도록 수정 #184
Changes from 3 commits
f999db4
445cb02
39006e5
7189932
a016925
d3fa095
1886a83
b4f96b8
22ab912
2ca0d57
948da00
62c0b7a
e78100d
8377bea
4fbb30f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package sopt.org.hmh.domain.dailychallenge.dto.response; | ||
|
||
import sopt.org.hmh.domain.dailychallenge.domain.Status; | ||
|
||
import java.util.List; | ||
|
||
public record ChallengeStatusesResponse( | ||
List<Status> statuses | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,13 @@ public void changeDailyChallengeStatusByIsSuccess(Long userId, FinishedDailyChal | |
} | ||
}); | ||
} | ||
|
||
public List<Status> getChangedChallengeStatuses(Long userId) { | ||
Long currentChallengeId = userService.getCurrentChallengeIdByUserId(userId); | ||
return challengeService.findByIdOrElseThrow(currentChallengeId) | ||
.getHistoryDailyChallenges() | ||
.stream() | ||
.map(DailyChallenge::getStatus) | ||
.toList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 찾는 로직을 사용하더라도 challengeDate로 정렬하는 로직이 추가되었으면 좋았을 것 같아요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그러면 기존 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
오호 그러면 너무 좋을 것 같아요! |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: 기존에
addFinishedDailyChallengeHistory
및changeDailyChallengeStatusByIsSuccess
에서 currentChallengeId도 찾아두었고, 그 currentChallenge를 통해 dailyChallenge에서 dailyChallenge를 찾는 로직도 있어서 이를 메서드를 분리해서 또 이를 찾는 것은 쿼리 낭비라는 생각이 들어요.Response를 주기 위해서 기존의 void였던
addFinishedDailyChallengeHistory
및changeDailyChallengeStatusByIsSuccess
의 메서드를 수정해서 response를 반환하는 것이 쿼리 성능 측면에서 나을 것으로 생각됩니다There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
또한, controller에 최대한 비즈니스 로직을 집어넣지 않기 위해서 facade 메서드를 controller에 최대한 줄이고자 하는데 이 의견에 대한 생각도 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 트랜잭션에 대해서 잘못 이해하고 있었네요!
수정 방향은 기존에 이미 불러온 챌린지 id를 활용할 수 있도록 챌린지를 구하고 다른 코드에서도 불러온 챌린지를 재활용하도록 코드를 수정하였고 return형태를 변경했습니다.
+) challengeService의
getCurrentChallengeAppByChallengeId()
호출을 삭제해서 이건 deprecated된 메소드에서만 호출되게 되었네요There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
또한, controller에 최대한 비즈니스 로직을 집어넣지 않기 위해서 facade 메서드를 controller에 최대한 줄이고자 하는데 이 의견에 대한 생각도 궁금합니다!
-> 컨트롤러에서는 facade나 service의 메서드 최대한 적게(이 로직을 수행하는 메서드 한 개정도로 연결하는 정도로) 호출하는 방향 말씀하시는거죵?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞습니다! controller layer에서는 최대한 비즈니스 로직을 제거하여 controller layer의 책임만 수행할 수 있도록 레이어간 책임 분리를 하는 것이 좋을 것 같아서요!