-
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
[DDING-110] 지원자 상세조회시 파일 다운로드 로직 처리 #255
Conversation
Caution Review failedThe pull request is closed. Walkthrough이번 변경 사항은 Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (7)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/entity/FormAnswer.java
(2 hunks)src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java
(4 hunks)src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/dto/query/FormApplicationQuery.java
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and analyze
🔇 Additional comments (6)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/entity/FormAnswer.java (2)
5-5
: 필요한 import 구문이 잘 추가되었습니다.
FieldType
enum을 사용하기 위한 import 구문이 적절히 추가되었습니다.
48-50
: 파일 타입 체크 메서드가 잘 구현되었습니다.메서드가 간단하고 명확하며, 단일 책임 원칙을 잘 따르고 있습니다.
src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/dto/query/FormApplicationQuery.java (2)
51-62
: 새로운 팩토리 메서드가 적절히 추가되었습니다.기존
from
메서드와 구분되는 새로운of
메서드가 추가되어 파일 URL과 같은 커스텀 값을 주입할 수 있게 되었습니다.
65-66
: 메서드 시그니처 변경이 적절합니다.
FormFieldAnswerListQuery
리스트를 직접 받도록 변경되어 파일 URL 처리와 같은 전처리된 데이터를 수용할 수 있게 되었습니다.src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java (2)
32-33
: 파일 관련 서비스 의존성이 잘 추가되었습니다.
FileMetaDataService
와S3FileService
가 적절히 주입되어 파일 처리 기능을 지원합니다.
59-60
: 리팩토링된 코드가 잘 적용되었습니다.기존 코드가 새로운
buildFormFieldAnswerQueries
메서드를 사용하도록 깔끔하게 수정되었습니다.
private List<FormFieldAnswerListQuery> buildFormFieldAnswerQueries(List<FormAnswer> formAnswers) { | ||
return formAnswers.stream() | ||
.map(formAnswer -> { | ||
if (formAnswer.isFile()) { | ||
String fileId = formAnswer.getValue().get(0); | ||
FileMetaData fileMetaData = fileMetaDataService.getById(fileId); | ||
String cdnUrl = s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()).cdnUrl(); | ||
return FormFieldAnswerListQuery.of(formAnswer, List.of(cdnUrl)); | ||
} | ||
return FormFieldAnswerListQuery.from(formAnswer); | ||
}) | ||
.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.
🛠️ Refactor suggestion
파일 처리 로직에 대한 개선이 필요합니다.
- 파일 메타데이터 조회 및 URL 생성 시 예외 처리가 필요합니다.
formAnswer.getValue().get(0)
는 리스트가 비어있을 경우 예외가 발생할 수 있습니다.- 스트림 연산이 많은 데이터를 처리할 때 성능 이슈가 발생할 수 있습니다.
다음과 같이 개선을 제안드립니다:
private List<FormFieldAnswerListQuery> buildFormFieldAnswerQueries(List<FormAnswer> formAnswers) {
return formAnswers.stream()
.map(formAnswer -> {
if (formAnswer.isFile()) {
- String fileId = formAnswer.getValue().get(0);
+ List<String> values = formAnswer.getValue();
+ if (values == null || values.isEmpty()) {
+ return FormFieldAnswerListQuery.of(formAnswer, List.of());
+ }
+ String fileId = values.get(0);
+ try {
FileMetaData fileMetaData = fileMetaDataService.getById(fileId);
String cdnUrl = s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()).cdnUrl();
return FormFieldAnswerListQuery.of(formAnswer, List.of(cdnUrl));
+ } catch (Exception e) {
+ log.error("파일 처리 중 오류 발생: {}", e.getMessage());
+ return FormFieldAnswerListQuery.of(formAnswer, List.of());
+ }
}
return FormFieldAnswerListQuery.from(formAnswer);
})
.toList();
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private List<FormFieldAnswerListQuery> buildFormFieldAnswerQueries(List<FormAnswer> formAnswers) { | |
return formAnswers.stream() | |
.map(formAnswer -> { | |
if (formAnswer.isFile()) { | |
String fileId = formAnswer.getValue().get(0); | |
FileMetaData fileMetaData = fileMetaDataService.getById(fileId); | |
String cdnUrl = s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()).cdnUrl(); | |
return FormFieldAnswerListQuery.of(formAnswer, List.of(cdnUrl)); | |
} | |
return FormFieldAnswerListQuery.from(formAnswer); | |
}) | |
.toList(); | |
} | |
private List<FormFieldAnswerListQuery> buildFormFieldAnswerQueries(List<FormAnswer> formAnswers) { | |
return formAnswers.stream() | |
.map(formAnswer -> { | |
if (formAnswer.isFile()) { | |
List<String> values = formAnswer.getValue(); | |
if (values == null || values.isEmpty()) { | |
return FormFieldAnswerListQuery.of(formAnswer, List.of()); | |
} | |
String fileId = values.get(0); | |
try { | |
FileMetaData fileMetaData = fileMetaDataService.getById(fileId); | |
String cdnUrl = s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()).cdnUrl(); | |
return FormFieldAnswerListQuery.of(formAnswer, List.of(cdnUrl)); | |
} catch (Exception e) { | |
log.error("파일 처리 중 오류 발생: {}", e.getMessage()); | |
return FormFieldAnswerListQuery.of(formAnswer, List.of()); | |
} | |
} | |
return FormFieldAnswerListQuery.from(formAnswer); | |
}) | |
.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.
고생하셨습니다!
|
🚀 작업 내용
🤔 고민했던 내용
💬 리뷰 중점사항
Summary by CodeRabbit