-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 기획 변경에 맞게 필터링 검색 기능 수정 #471
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
Merged
nayonsoso
merged 8 commits into
solid-connection:develop
from
nayonsoso:469/refactor-univ-apply-info-filter-search
Aug 24, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1f1aca6
refactor: 레포지토리 구현체가 아니라 인터페이스 의존하도록
nayonsoso c5f2171
refactor: API 명세에 맞게 컨트롤러, 요청 구현
nayonsoso ce63b5a
feat: 대학지원정보 필터링 검색 기능 구현
nayonsoso 0273f67
chore: 사용하지 않는 메서드 제거
nayonsoso 816f9f8
refactor: 람다 표현식 간소화
nayonsoso 303ee8d
chore: 주석 수정
nayonsoso f3476fb
test: 바뀐 로직을 테스트 코드에 반영
nayonsoso be19f52
test: 더 엄격한 검증 적용
nayonsoso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ain/java/com/example/solidconnection/university/dto/UnivApplyInfoFilterSearchRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.example.solidconnection.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.LanguageTestType; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.util.List; | ||
|
|
||
| public record UnivApplyInfoFilterSearchRequest( | ||
|
|
||
| @NotNull(message = "어학 시험 종류를 선택해주세요.") | ||
| LanguageTestType languageTestType, | ||
| String testScore, | ||
| List<String> countryCode | ||
| ) { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| package com.example.solidconnection.university.repository.custom; | ||
|
|
||
| import com.example.solidconnection.location.country.domain.QCountry; | ||
| import com.example.solidconnection.location.region.domain.QRegion; | ||
| import com.example.solidconnection.university.domain.LanguageTestType; | ||
| import com.example.solidconnection.university.domain.QLanguageRequirement; | ||
| import com.example.solidconnection.university.domain.QUnivApplyInfo; | ||
|
|
@@ -70,43 +69,71 @@ private BooleanExpression createKeywordCondition(StringPath namePath, List<Strin | |
| } | ||
|
|
||
| @Override | ||
| public List<UnivApplyInfo> findAllByRegionCodeAndKeywordsAndLanguageTestTypeAndTestScoreAndTerm( | ||
| String regionCode, List<String> keywords, LanguageTestType testType, String testScore, String term) { | ||
| public List<UnivApplyInfo> findAllByFilter( | ||
| LanguageTestType testType, String testScore, String term, List<String> countryCodes | ||
| ) { | ||
| QUniversity university = QUniversity.university; | ||
| QCountry country = QCountry.country; | ||
| QRegion region = QRegion.region; | ||
| QUnivApplyInfo univApplyInfo = QUnivApplyInfo.univApplyInfo; | ||
| QCountry country = QCountry.country; | ||
| QLanguageRequirement languageRequirement = QLanguageRequirement.languageRequirement; | ||
|
|
||
| List<UnivApplyInfo> filteredUnivApplyInfo = queryFactory | ||
| .selectFrom(univApplyInfo) | ||
| List<UnivApplyInfo> filteredUnivApplyInfo = queryFactory.selectFrom(univApplyInfo) | ||
| .join(univApplyInfo.university, university) | ||
| .join(university.country, country) | ||
| .join(university.region, region) | ||
| .where(regionCodeEq(country, regionCode) | ||
| .and(countryOrUniversityContainsKeyword(country, university, keywords)) | ||
| .and(univApplyInfo.term.eq(term))) | ||
| .join(univApplyInfo.languageRequirements, languageRequirement) | ||
| .fetchJoin() | ||
| .where( | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| languageTestTypeEq(languageRequirement, testType), | ||
| termEq(univApplyInfo, term), | ||
| countryCodesIn(country, countryCodes) | ||
| ) | ||
| .distinct() | ||
| .fetch(); | ||
|
|
||
| if (testScore == null || testScore.isEmpty()) { | ||
| if (testType != null) { | ||
| return filteredUnivApplyInfo.stream() | ||
| .filter(uai -> uai.getLanguageRequirements().stream() | ||
| .anyMatch(lr -> lr.getLanguageTestType().equals(testType))) | ||
| .toList(); | ||
| } | ||
| if (testScore == null || testScore.isBlank()) { | ||
| return filteredUnivApplyInfo; | ||
| } | ||
|
|
||
| /* | ||
| * 시험 유형에 따라 성적 비교 방식이 다르다. | ||
| * 입력된 점수가 대학에서 요구하는 최소 점수보다 높은지를 '쿼리로' 비교하기엔 쿼리가 지나치게 복잡해진다. | ||
| * 따라서 이 부분만 자바 코드로 필터링한다. | ||
| * */ | ||
| return filteredUnivApplyInfo.stream() | ||
| .filter(uai -> compareMyTestScoreToMinPassScore(uai, testType, testScore) >= 0) | ||
| .filter(uai -> isGivenScoreOverMinPassScore(uai, testType, testScore)) | ||
| .toList(); | ||
| } | ||
|
Comment on lines
+97
to
105
Collaborator
Author
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. LanguageTestType enum 을 확인하시면 아시겠지만, 앞에도 언급했듯, 한 학기에 열리는 대학은 약 400여개입니다. |
||
|
|
||
| private int compareMyTestScoreToMinPassScore(UnivApplyInfo univApplyInfo, LanguageTestType testType, String testScore) { | ||
| private BooleanExpression languageTestTypeEq( | ||
| QLanguageRequirement languageRequirement, LanguageTestType givenTestType | ||
| ) { | ||
| if (givenTestType == null) { | ||
| return null; | ||
| } | ||
| return languageRequirement.languageTestType.eq(givenTestType); | ||
| } | ||
|
|
||
| private BooleanExpression termEq(QUnivApplyInfo univApplyInfo, String givenTerm) { | ||
| if (givenTerm == null || givenTerm.isBlank()) { | ||
| return null; | ||
| } | ||
| return univApplyInfo.term.eq(givenTerm); | ||
| } | ||
|
|
||
| private BooleanExpression countryCodesIn(QCountry country, List<String> givenCountryCodes) { | ||
| if (givenCountryCodes == null || givenCountryCodes.isEmpty()) { | ||
| return null; | ||
| } | ||
| return country.code.in(givenCountryCodes); | ||
| } | ||
|
|
||
| private boolean isGivenScoreOverMinPassScore( | ||
| UnivApplyInfo univApplyInfo, LanguageTestType givenTestType, String givenTestScore | ||
| ) { | ||
| return univApplyInfo.getLanguageRequirements().stream() | ||
| .filter(languageRequirement -> languageRequirement.getLanguageTestType().equals(testType)) | ||
| .filter(languageRequirement -> languageRequirement.getLanguageTestType().equals(givenTestType)) | ||
| .findFirst() | ||
| .map(requirement -> testType.compare(testScore, requirement.getMinScore())) | ||
| .orElse(-1); | ||
| .map(requirement -> givenTestType.compare(givenTestScore, requirement.getMinScore())) | ||
| .orElse(-1) >= 0; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
고민한 지점 : 페이지네이션으로 내려줘야 할지, 검색 결과를 한번에 내려줘야할지 고민이 되었습니다.
그런데 뒤에 언급하는 내용처럼
점수의 경우 DB단에서 비교하기가 매우 까다롭기 때문에 메모리에서 필터링 하는데
이때 페이지네이션을 적용하기 까다롭다는 점과,
한 학기의 대학 지원 정보가 약 400개정도이므로, 엄청난 성능 저하는 있지 않을것이라 판단하여
검색된 결과 전체를 반환하도록 구현했습니다!