-
Notifications
You must be signed in to change notification settings - Fork 0
이번 주 인기 쇼츠 기능 구현 #21
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
Open
ericKwon95
wants to merge
9
commits into
develop
Choose a base branch
from
feature/this-week-popular-shorts
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
이번 주 인기 쇼츠 기능 구현 #21
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6df854d
feat: 인기 쇼츠 리듀서 구현
ericKwon95 503960a
feat: 인기 쇼츠 화면 스토어 생성
ericKwon95 830ad50
chore: print 삭제
ericKwon95 1616d02
feat: 암장 난이도 정보 가져오기 구현
ericKwon95 a0781ec
feat: 쇼츠 위 루트 난이도 뱃지 구현
ericKwon95 8c00359
chore: pbxproj 설정
ericKwon95 5e189c5
fix: opaque 타입 반환 함수에서 여러 타입 반환하는 문제 수정
ericKwon95 3c344b2
feat: 커스텀 크기 폰트 기능 구현
ericKwon95 f6f1c78
feat: 쇼츠 상단 암장 정보 표시 뷰 구현
ericKwon95 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
2 changes: 1 addition & 1 deletion
2
Climeet-iOS/Climeet-iOS.xcodeproj/xcshareddata/xcschemes/Climeet-iOS.xcscheme
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
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
22 changes: 22 additions & 0 deletions
22
Climeet-iOS/Climeet-iOS/Presentation/Home/WeeklyPopularShorts/Model/GymDifficulty.swift
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,22 @@ | ||
| // | ||
| // GymDifficulty.swift | ||
| // Climeet-iOS | ||
| // | ||
| // Created by 권승용 on 11/29/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct GymDifficulty: Equatable { | ||
| let level: Int | ||
| let color: String | ||
|
|
||
| init(from dto: DifficultyMappingDTO.GymDifficulty.ResponseElement) throws { | ||
| guard let level = dto.difficulty, | ||
| let color = dto.gymDifficultyColor else { | ||
| throw AppError.dataParsingError("dto property nil") | ||
| } | ||
| self.level = level | ||
| self.color = color | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
Climeet-iOS/Climeet-iOS/Presentation/Home/WeeklyPopularShorts/Model/PopularShorts.swift
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,25 @@ | ||
| // | ||
| // PopularShorts.swift | ||
| // Climeet-iOS | ||
| // | ||
| // Created by 권승용 on 11/29/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct PopularShorts: Equatable, Identifiable { | ||
| let id = UUID() | ||
| let gymName: String | ||
| let thumbnailImageURL: String | ||
| let difficulty: GymDifficulty | ||
|
|
||
| init(from dto: ShortsDTO.Shorts.Response, difficulty: GymDifficulty) throws { | ||
| guard let gymName = dto.gymName, | ||
| let thumbnailImageURL = dto.thumbnailImageURL else { | ||
| throw AppError.dataParsingError("dto property nil") | ||
| } | ||
| self.gymName = gymName | ||
| self.thumbnailImageURL = thumbnailImageURL | ||
| self.difficulty = difficulty | ||
| } | ||
| } |
73 changes: 73 additions & 0 deletions
73
...et-iOS/Climeet-iOS/Presentation/Home/WeeklyPopularShorts/WeeklyPopularShortsReducer.swift
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,73 @@ | ||
| // | ||
| // WeeklyPopularShortsReducer.swift | ||
| // Climeet-iOS | ||
| // | ||
| // Created by 권승용 on 11/26/24. | ||
| // | ||
|
|
||
| import Foundation | ||
| import ComposableArchitecture | ||
|
|
||
| @Reducer | ||
| struct WeeklyPopularShortsReducer { | ||
| @ObservableState | ||
| struct State: Equatable { | ||
| var shortsItems: IdentifiedArrayOf<PopularShorts> = [] | ||
| } | ||
|
|
||
| enum Action { | ||
| case onFirstAppear | ||
| case popularShortsResponse([PopularShorts]) | ||
| } | ||
|
|
||
| @Dependency(\.shortsClient) var shortsClient | ||
| @Dependency(\.difficultyMappingClient) var difficultyMappingClient | ||
|
|
||
| var body: some ReducerOf<Self> { | ||
| Reduce { state, action in | ||
| switch action { | ||
| case .onFirstAppear: | ||
| return .run { send in | ||
| let request = ShortsDTO.List.Request(page: 0, size: 10) | ||
| let response = try await shortsClient.popularShorts(request) | ||
|
|
||
| let result = try await withThrowingTaskGroup(of: PopularShorts?.self) { group in | ||
| for responseItem in response.result { | ||
| group.addTask { | ||
| guard let id = responseItem.shortsDetailInfo?.gymID else { | ||
| throw AppError.dataParsingError("gymID not found") | ||
| } | ||
|
|
||
| let difficulty = try await difficultyMappingClient.gymDifficulty(id) | ||
|
|
||
| guard !difficulty.isEmpty else { return nil } | ||
|
|
||
| return try PopularShorts( | ||
| from: responseItem, | ||
| difficulty: try GymDifficulty(from: difficulty[0]) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| var popularShorts: [PopularShorts] = [] | ||
|
|
||
| for try await item in group { | ||
| if let item = item { | ||
| popularShorts.append(item) | ||
| } | ||
| } | ||
|
|
||
| return popularShorts | ||
| } | ||
|
|
||
| await send(.popularShortsResponse(result)) | ||
| } | ||
|
|
||
| case let .popularShortsResponse(response): | ||
| state.shortsItems = IdentifiedArray(uniqueElements: response) | ||
| print(state.shortsItems) | ||
| return .none | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
withThrowingTaskGroup 쓰신 이유가 무엇일까요?
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.
여러 개의 비동기 작업을 concurrent하게 처리하기 위함입니다.
반복문 안에 await을 사용할 시 해당 작업이 끝난 후 다음 반복문이 serial하게 수행됩니다.
이를 concurrent하게 수행하고 싶어 사용해 보았습니다~
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.
제가 파악하고 있는게 맞는지 확인 부탁드려도 될까요?!
이번주 인기숏츠영상별 뱃지를 표현하기 위해 gymDifficulty API를 반복해서 호출하는 것으로 보이는데 성능저하, 즉 네트워킹환경에 따라서 무기한 대기상황을 초래할 수도 있다 생각되서요! 그래서 찾아보니 popularShorts API Response에 gymDifficultyName, gymDifficultyColor가 존재하는데 이것으로는 해결이 안 되는 것일까요?!
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.
현재 각 난이도에 따른 레벨 표시(V1, V3 등) 값을 알기 위해 추가적인 API 호출이 필요한 상황입니다..!
형욱님이 알려주신 부분은 쇼츠 썸네일 정보를 위해 과다한 API 호출이 이루어진다는 점인 것으로 이해됩니다.
그 부분 저도 동의하고 있습니다~ API 호출을 최대한 줄이고 싶은데, 현재 쇼츠 API 구성의 한계로 인해 이렇게 구현하였습니다 ㅜㅜ
혹시 더 좋은 방법이 있을까요?