-
Notifications
You must be signed in to change notification settings - Fork 3
✨ 지원자 현황을 소속 대학 기준으로 필터링 #627
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
+79
−1
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { ApplicationListResponse, ScoreSheet } from "@/types/application"; | ||
|
|
||
| /** | ||
| * 지원자 현황 응답을 소속 대학 기준으로 걸러내기 위한 키. | ||
| * | ||
| * `GET /applications` 응답(ScoreSheet)에는 홈 대학 식별자도, 지원 정보 id 도 없다. | ||
| * 그래서 파견학교 목록과 겹치는 필드(파견학교명 + 국가 + 모집인원)를 합쳐 식별한다. | ||
| * | ||
| * 파견학교명만으로는 부족하다. 서로 다른 홈 대학이 같은 이름의 파견학교를 가질 수 있고 | ||
| * (예: 경희대·중앙대 모두 보유한 국립정치대학교), 그 경우 이름만으로는 구분되지 않는다. | ||
| */ | ||
| type ScopeKeySource = { | ||
| koreanName: string; | ||
| country: string; | ||
| studentCapacity: number | null; | ||
| }; | ||
|
|
||
| export const createHomeUniversityScopeKey = ({ koreanName, country, studentCapacity }: ScopeKeySource): string => | ||
| `${koreanName}|${country}|${studentCapacity ?? ""}`; | ||
|
|
||
| /** | ||
| * 소속 대학의 파견학교 목록에 포함된 항목만 남긴다. | ||
| * 기준 목록이 비어 있으면 필터링하지 않고 원본을 그대로 돌려준다. | ||
| */ | ||
| export const filterApplicationsByHomeUniversityScope = ( | ||
| applications: ApplicationListResponse, | ||
| scopedUniversities: ScopeKeySource[] | undefined, | ||
| ): ApplicationListResponse => { | ||
| if (!scopedUniversities || scopedUniversities.length === 0) { | ||
| return applications; | ||
| } | ||
|
|
||
| const allowedKeys = new Set(scopedUniversities.map(createHomeUniversityScopeKey)); | ||
|
|
||
| return { | ||
| choices: applications.choices.map((scoreSheets: ScoreSheet[]) => | ||
| scoreSheets.filter((scoreSheet) => allowedKeys.has(createHomeUniversityScopeKey(scoreSheet))), | ||
| ), | ||
| }; | ||
| }; | ||
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.
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.
When an authenticated user's scope request is still loading, fails, or legitimately returns zero universities, this branch returns the complete
/applicationsresponse. BecauseuseGetApplicationsListexposes only the applications query's loading/error state, bothApprovedApplicationStatusPageand the university-detail page can then render applicants from other home universities—briefly during ordinary request races and indefinitely after a scope-query failure. Keep the result loading/erroring until the scope resolves, and treat a successful empty scope as an empty filtered result rather than returning all applications.Useful? React with 👍 / 👎.