-
Notifications
You must be signed in to change notification settings - Fork 0
feat(report): 오늘의 리포트 생성 API 구현 #59
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
Conversation
스웨거 문서화 추가 등
DailyQuestionResponse 클래스에 interestCode 필드 추가
|
오늘의 질문에 대해 일단 한번 입력된 답변은 저장되기 때문에, |
| DailyQuestion question = dailyQuestionRepository.findById(request.questionId()) | ||
| .orElseThrow(() -> new NotFoundException("질문을 찾을 수 없습니다. id: " + request.questionId())); | ||
|
|
||
| PrepareDailyResultDto prep = dailyReportTxService.prepareDaily(user, question, request.answer()); |
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.
prepareDaily 메서드에서 answerEntryService.getOrCreateTodayAnswerEntry()로 answerEntry를 조회하고 그 후에 answerEntryRepository.findById()로 또 조회해서 중복되는거 같은데 한 번 조회하도록 줄일 수 있을까요??
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.
Dto에 AnswerEntry 자체를 포함시켜서 중복 제거했습니다
| throw e; | ||
| } | ||
|
|
||
| long balanceAfter = dailyReportTxService.confirmDailyAndReward(prep, dto); |
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.
이 부분에서도 confirmDailyAndReward 메서드에서 emotionRepository.findByName을 호출하는데 그 후에 emotionRepository.findByName로 중복 호출되는거 같아서 확인 부탁드립니다!
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.
이것도 Emotion 객체와 balanceAfter를 필드로 갖는 Dto를 따로 두어 중복을 제거했습니다
prepareDaily 메소드에서 AnswerEntry 조회 중복 제거, confirmDailyAndReward 메소드에서 Emotion 조회 중복 제거
|
고생하셨어요!! |
📝 요약(Summary)
테이블 및 엔티티
emotions,daily_reports테이블 생성 및 엔티티 구현 + 시드오늘의 리포트 생성 API 구현
전체적인 플로우는 아래와 같습니다. 이와 같이 구성한 이유는
LLM을 사용한 리포트 생성 시에 약 3~4초의 시간이 소요되기 때문에
리포트 생성을 포함해서 모든 과정을 하나의 트랜잭션으로 묶으면
DB 커넥션 점유/락 경합/타임아웃/스루풋 저하 등 여러 문제가 발생할 수 있기 때문입니다.
실패 시 오늘의 리포트 생성을 다시 시도하여도 동일한 답변으로 시도됩니다.
오늘의 리포트 조회 API 구현
🔗 Related Issue
💬 공유사항
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.