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

Add(.remind): 피드백 가능한 계획 목록 조회 API 구현 #199

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

2jie0516
Copy link
Contributor

🔍 어떤 PR인가요?

  • 홈에서 피드백 가능한 계획들을 가져오는 API를 구현하였습니다.

image

😋 To Reviewer

  • 매퍼에서 하드 코딩 된 로직을 수정하였습니다.

✅ 작성한 테스트

  • getUpdatableFeedbacks_Success_WithNoException

@2jie0516 2jie0516 self-assigned this Mar 17, 2024
Copy link

Test Coverage Report

Overall Project 70% -1.78% 🍏
Files changed 17.57%

File Coverage
FindTargetRemindAdapter.java 100% 🍏
FeedbackController.java 100% 🍏
Plan.java 53.7% -10.89%
LoadUpdatableFeedbackService.java 0%
UpdatableFeedback.java 0%
FindUpdatableTargetsAdapter.java 0%

Copy link
Member

@Hejow Hejow left a comment

Choose a reason for hiding this comment

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

작성하시느라 고생하셨어요!
리뷰 한번 확인 바랍니당 ㅎㅎ

Copy link
Member

@JuwoongKim JuwoongKim left a comment

Choose a reason for hiding this comment

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

세한님 PR 리뷰가 늦었네요!!
고생하셨습니다!!
리뷰 몇개 남겨봤습니다!

Copy link

Test Coverage Report

Overall Project 70.11% -1.73% 🍏
Files changed 19.73%

File Coverage
UpdateFeedbackService.java 100% 🍏
FindTargetRemindAdapter.java 100% 🍏
FeedbackController.java 100% 🍏
Plan.java 53.7% -10.89%
LoadEvaluableFeedbacksService.java 0%
LoadEvaluablePlansService.java 0%
UpdatableFeedback.java 0%
FindEvaluablePlansAdapter.java 0%

Copy link
Member

@Hejow Hejow left a comment

Choose a reason for hiding this comment

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

작성하시느라 고생 많으셨어요!
이번 기회로 전체적으로 코드 둘러봤는데 의미없이 노출된 메서드가 많지 않았나? 라는 생각이 들었습니다! 겸4겸4 한번 확인해봐도 좋을 것 같아요!
리뷰도 확인 바랍니당 ㅎㅎ

src/main/java/me/ajaja/global/common/BaseTime.java Outdated Show resolved Hide resolved
@@ -46,4 +50,14 @@ public AjajaResponse<FeedbackResponse.FeedbackInfo> getFeedbackInfo(@PathVariabl
FeedbackResponse.FeedbackInfo feedbackInfo = loadFeedbackInfoService.loadFeedbackInfoByPlanId(userId, planId);
return AjajaResponse.ok(feedbackInfo);
}

@Authorization
@GetMapping("/updatable")
Copy link
Member

@Hejow Hejow Mar 20, 2024

Choose a reason for hiding this comment

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

하 뭔가 좋은 엔드포인트가 있을 것 같은데... 고민되네요
그냥 컨트롤 URI로 쓰는것도 괜찮을 것 같은데 어떤가요??

// 전
curl -X GET https://api.ajaja.me/feedbacks/updatable

// 후
curl -X GET https://api.ajaja.me/feedbacks/추천좀요

그리고 변수명 수정하면서 엔드포인트는 수정 안되었군요!? ㅋㅋ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6b96c34
"평가 가능한 피드백" 을 나타낼 수 있는게 뭔가 고민해보았는데 흠흠
평가 + able + 복수형 = evaluables 로 해보았는데 어떤가유 ㅋㅋ
이번꺼 네이밍이 전반적으로 애매하네요..

Copy link
Member

Choose a reason for hiding this comment

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

evaluables 이게 나쁘지 않은 것 같기두용 ㅎㅎ?

src/main/java/me/ajaja/module/plan/domain/Plan.java Outdated Show resolved Hide resolved
Copy link

Test Coverage Report

Overall Project 69.39% -2.37% 🍏
Files changed 33.47%

File Coverage
UpdateFeedbackService.java 100% 🍏
FindTargetRemindAdapter.java 100% 🍏
FeedbackController.java 100% 🍏
FeedbackQueryRepositoryImpl.java 79.89% 🍏
RemindInfo.java 67.11% 🍏
Message.java 60% -40%
Plan.java 55.87% -13.36%
LoadEvaluableFeedbacksService.java 0%
LoadFeedbackService.java 0%
LoadEvaluablePlansService.java 0%
UpdatableFeedback.java 0%
FindEvaluablePlansAdapter.java 0%

Copy link
Member

@Hejow Hejow 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 +15 to +24
@Getter
@RequiredArgsConstructor
private enum RemindTime {
MORNING(9),
AFTERNOON(13),
EVENING(22);

private final int time;
}

Copy link
Member

@Hejow Hejow Mar 23, 2024

Choose a reason for hiding this comment

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

이렇게 내부에서 쓰도록 변경했다면, 다음과 같이 불필요한 코드라인 수를 줄일 수 있을 것 같아요!
또한 외부에서 안쓰이니까 접근지정자를 개선할 수 있을 것 같구요!

public int getRemindTime() {
    // before
    return remindTime.getTime();

    // after
    return remindTime.time;
}

Comment on lines +154 to +155
return this.messages.stream().anyMatch(message -> now.isWithinAMonth(
message.parsePeriod(this.createdAt.getYear(), this.getRemindTime())
Copy link
Member

@Hejow Hejow Mar 23, 2024

Choose a reason for hiding this comment

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

가독성이 떨어져서 라인을 좀 바꿀까요?? 아니면 저처럼 map 쓰셔도 괜찮구!


@Override
public List<UpdatableFeedback> findEvaluableTargetsByUserId(Long userId) {
BaseTime now = BaseTime.now();
Copy link
Member

@Hejow Hejow Mar 23, 2024

Choose a reason for hiding this comment

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

method 네이밍이 괜찮아서 바로 사용해도 괜찮을 것 같아요!

Comment on lines +24 to +32
public List<Plan> findEvaluablePlansByUserIdAndTime(Long id, BaseTime now) {
return queryFactory.selectFrom(planEntity)
.where(planEntity.userId.eq(id)
.and(planEntity.createdAt.year().eq(now.getYear())))
.fetch()
.stream()
.map(mapper::toDomain)
.toList();
}
Copy link
Member

Choose a reason for hiding this comment

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

네이밍과 쿼리 사이 연관성이 없는 것 같아요..!
그리고 querydsl을 이렇게 쓸거면 JPA로만 처리할 수 있을 것 같아요!

Comment on lines +40 to +46
List<FeedbackEntity> entities = queryFactory.selectFrom(feedbackEntity)
.where(feedbackEntity.userId.eq(userId)
.and(feedbackEntity.createdAt.year().eq(BaseTime.now().getYear())))
.orderBy(feedbackEntity.planId.asc())
.fetch();

return mapper.toDomain(entities);
Copy link
Member

Choose a reason for hiding this comment

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

다른 곳에서는 stream()으로 잘 넘기시는데 여기서는 달라서 코드에 통일성이 없어 보여요!
아마 원인이 mapper의 문제인 것 같은데 toDomain()으로 넘기는 것과 달리 결과는 List로 받으니 mapper 네이밍의 문제인 것 같습니다!

public List<Feedback> findAllFeedbacksByUserId(Long userId) {
List<FeedbackEntity> entities = queryFactory.selectFrom(feedbackEntity)
.where(feedbackEntity.userId.eq(userId)
.and(feedbackEntity.createdAt.year().eq(BaseTime.now().getYear())))
Copy link
Member

@Hejow Hejow Mar 23, 2024

Choose a reason for hiding this comment

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

최저수준에서 직접적으로 application 코드를 사용하라는 의도는 아니였습니다!
repository의 재사용성을 고려해서 시간은 외부에서 받도록!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants