-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FEAT] 리뷰 폼 생성 및 공유하기 #6
Conversation
project, reviewform, user 관련 errorcode
review request 알람 생성 시 활용 Related to: #4
Related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
related to: #4
realted to: #4
batchInsert를 통한 성능 개선 related to: #4
batch insert를 통한 성능 개선 기본 옵션 삽입 시 사용 related to: #4
batch insert를 통한 성능 개선 리뷰 폼 생성 및 공유 시 사용 related to: #4
related to: #4
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.
reviewService.createReviewForm 에서 실행되는 로직은 categorType에 따라서 캐싱을 할 수 있다면 처리하는것도 좋을 것 같아요
수고하셨어요~!
String content) { | ||
Member receiver = memberRepository.findById(receiverId).orElseThrow(() | ||
-> new RestApiException(UserErrorCode.USER_NOT_FOUND)); | ||
content = sender.getName() + content; |
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.
Alarm이라는 도메인에 관련된 내용이니 Alarm Entity에 관련된 내용이 포함시켜도 좋을 것 같아요
setContent 함수에 들어갈 수도 있지 않을까 싶네요?
|
||
@Getter | ||
@NoArgsConstructor | ||
@MappedSuperclass | ||
@EntityListeners(AuditingConfiguration.class) | ||
@EntityListeners(AuditingEntityListener.class) |
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.
제가 다른 Class를 적어두었었네요. 수정해주셔서 감사해요
} | ||
} | ||
|
||
private void addCategoryQuestionsAndOptions(List<Question> allQuestions, List<ChoiceOption> allChoiceOptions, CategoryType categoryType, List<QuestionWithOptions> questionWithOptionsList) { |
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.
이부분 Intellij code Style이 적용이 안된 것 같아요!
private void setDefaultQuestionsAndChoiceOption() { | ||
|
||
// DB에 데이터 없는 경우만 새로 생성 | ||
if (questionRepository.count() == 0 && choiceOptionRepository.count() == 0) { |
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.
[optional]
Count vs Exitsts 키워드간 성능차이가 있다고 하네요
이는 exists는 첫번째 결과에서 바로 true 를 리턴하면 되지만, count의 경우엔 결국 총 몇건인지 확인하기 위해 전체를 확인해봐야하기 때문에 성능 차이는 당연할 수 밖에 없습니다.
allChoiceOptions, | ||
COMMUNICATION, | ||
List.of( | ||
new QuestionWithOptions( |
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.
하드코딩된 부분은 .json 파일로 따로 빼는게 가독성에 좋을 것 같아요.
question.json
[
{
"categoryType": "COMMUNICATION",
"questions": [
{
"text": "${nickname}님은 회의 중 의견을 나눌 때 어떠했나요?",
"options": [
"명확하고 논리적으로 의견을 전달하였다.",
"의견이 모호하여 이해하기 어려운 경우가 있었다.",
"회의 중 의견을 나누지 않았다.",
"의견을 잘 전달했으나 다른 의견을 듣는 데는 소극적이었다."
]
},
{
"text": "${nickname}님은 슬랙과 같은 온라인 커뮤니케이션에서 어떻게 대응했나요?",
"options": [
"빠르고 정확한 답변을 제공하였다.",
"답변이 늦거나 불명확한 경우가 있었다.",
"이메일에 대한 대응이 거의 없었다.",
"답변은 빠르지만 내용이 부실하였다."
]
}
// 나머지 질문과 선택지들...
]
},
{
"categoryType": "COLLABORATION",
"questions": [
{
"text": "${nickname}님이 팀 프로젝트에서 역할을 수행하는 태도는 어땠나요?",
"options": [
"적극적으로 자신의 역할을 수행하고 팀을 지원하였다.",
"자신의 역할은 수행했으나 팀 지원은 부족하였다.",
"자신의 역할조차 제대로 수행하지 못하였다.",
"역할 수행은 잘했으나 팀과의 협력은 부족하였다."
]
}
// 나머지 질문과 선택지들...
]
}
// 나머지 카테고리들...
]
Resource resource = new ClassPathResource("questions.json");
List<CategoryQuestions> categoryQuestionsList = objectMapper.readValue(resource.getInputStream(),
new TypeReference<List<CategoryQuestions>>() {});
.flatMap(category -> questionRepository.findByCategoryType(category).stream()) | ||
.collect(Collectors.toList()); | ||
if (questions.isEmpty()) { | ||
throw new RestApiException(ReviewErrorCode.QUESTION_NOT_FOUND); |
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.
브라우저에서 입력된 요청값 "categories"가 controller단에서 유효성검사를 마치고 나면, question.isEmtpy인 경우는 DB상 카테고리타입에 해당하는 질문들이 없는 경우이니
해당하는 카테고리에 속하는 질문이 없습니다라고 보다 명시적으로 error message가 작성되면 좋을 것 같아요
String message = "님이 리뷰를 요청했습니다."; | ||
request.getReviewerIdList().forEach(reviewerId -> | ||
alarmService.createAlarm(result.getSender(), reviewerId, AlarmType.REVIEW_REQUEST, result.getReviewFormId(), message) | ||
); |
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.
알림생성 부분은 서비스단에 코드가 위치해야할 것 같아요
.collect(Collectors.toList()); | ||
reviewQuestionJdbcRepository.batchInsert(reviewQuestions); | ||
|
||
return ReviewFormCreateResponse.builder() |
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.
ResponseDto도 정적팩토리 메서드를 활용하면 어떨까요?
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.
넵 좋습니다!
List<CategoryType> categories = request.getCategories(); | ||
List<Question> questions = categories.stream() | ||
.flatMap(category -> questionRepository.findByCategoryType(category).stream()) | ||
.collect(Collectors.toList()); |
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.
.toList()만 사용해도 되는 것 같아요 (IDE 추천)
|
||
private final JdbcTemplate jdbcTemplate; | ||
|
||
public void batchInsert(List<ReviewQuestion> reviewQuestions) { |
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.
batchInsert는 이런식으로 진행되는군요! 첨알았네요
네! 리뷰를 요청할 팀원 list 조회 요청을 할때 응답값으로 이미 요청을 보낸 팀원인지도 같이 응답해주면 될 것 같아요.
리뷰폼생성 로직과 리뷰요청알림 로직은 분리될 수도 있을 것 같다는 생각이 들긴하는데, 제가 질문 이해를 정확히 못한것 같아요. 혹시 고민이되신 피그마 화면을 공유해주실 수 있을까요?
|
✏️ Description
🙏🏻 To Reviewers
💡 Issue Number