Skip to content
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

[Feat] #153- 출석 조회하기 API 연결 #157

Merged
merged 19 commits into from
Apr 16, 2023

Conversation

devxsby
Copy link
Member

@devxsby devxsby commented Apr 15, 2023

🌴 PR 요약

🌱 작업한 브랜치

🌱 PR Point

  • 출석 조회하기 뷰 API 연결
  • 코드가 별로인거같아요(특히 프레젠테이션 레이어 데이터 연결하는 로직). 리뷰 좀 부탁드려용 🤔

📌 참고 사항

  • 토큰이 없어서 일단 mock data로 넣어놨고 머지하기전에 토큰 받아서 확인하고 풀리퀘 머지할게요!
  • 엠티뷰(네트워크 연결 제대로 안됐을때)가 맘에 안들어서 레이아웃만 추후에 조금 더 다듬겠습니다~~!

📸 스크린샷

Simulator Screen Recording - iPhone 14 Pro - 2023-04-15 at 22 21 34

📮 관련 이슈

@devxsby devxsby added Feat 새로운 기능 구현 윤수🥚 labels Apr 15, 2023
@devxsby devxsby self-assigned this Apr 15, 2023
Copy link
Member

@lsj8706 lsj8706 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~~!!

Comment on lines +29 to +35
// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
// location: "단국대학교 혜당관",
// name: "3차 세미나",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
// TodayAttendanceModel(status: "ABSENT", attendedAt:
// "2023-04-13T14:10:04")])))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구들은 토큰 받아오면 없어질 예정이겠죠..?


import Foundation

public struct AttendanceScheduleModel: Codable, Hashable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashable을 채택한 이유가 궁금합니다!

image: DSKitAsset.Assets.opStateAttendance.image,
date: "4월 \(indexPath.row*7+1)일")
updateTableviewHeight()
cell.setData(model: attendanceModelList[safe: indexPath.row]!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 강제 언래핑을 한거라면 굳이 safe를 사용할 필요가 없을 것 같아요..!

.store(in: self.cancelBag)

output.$scoreModel
.sink { model in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 weak self 필요할 것 같아요!

Copy link
Contributor

@L-j-h-c L-j-h-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고 많으셨습니다!

Comment on lines +100 to +123
private func convertDateString(_ dateString: String) -> String? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
guard let date = dateFormatter.date(from: dateString) else { return nil }

dateFormatter.dateFormat = "M월 d일 EEEE H:mm"
dateFormatter.locale = Locale(identifier: "ko_KR")
dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul")
return dateFormatter.string(from: date)
}

func formatTimeInterval(startDate: String, endDate: String) -> String? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "M월 d일 EEEE HH:mm"

guard let startDateObject = dateFormatter.date(from: startDate),
let endDateObject = dateFormatter.date(from: endDate) else { return nil }

let formattedStartDate = dateFormatter.string(from: startDateObject)

dateFormatter.dateFormat = "HH:mm"
let formattedEndDate = dateFormatter.string(from: endDateObject)

return "\(formattedStartDate) ~ \(formattedEndDate)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분은 Core에 Extension으로 빼줘도 좋을 것 같아요~

Comment on lines +71 to +97
fetchedSchedule.asDriver()
.sink(receiveValue: { model in
if model.type != SessionType.noSession.rawValue {
self.sceneType = .scheduledDay
guard let convertedStartDate = self.convertDateString(model.startDate),
let convertedEndDate = self.convertDateString(model.endDate) else { return }

let newModel = AttendanceScheduleModel(type: model.type,
location: model.location,
name: model.name,
startDate: convertedStartDate,
endDate: convertedEndDate,
message: model.message,
attendances: model.attendances)
output.scheduleModel = newModel
} else {
self.sceneType = .unscheduledDay
output.scheduleModel = model
}
})
.store(in: cancelBag)

fetchedScore.asDriver()
.sink(receiveValue: { model in
output.scoreModel = model
})
.store(in: cancelBag)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분에서 fetchedSchedule과 fetchedScore의 순서가 서로에게 미치는 영향이 없을까요??

만약 순서가 중요하다면, viewDidload publisher를 받아서 한 번의 useCase 함수 호출만 하고, repository에서 flatMap을 통해 서버 호출을 순서대로 할 수 있어요!

Comment on lines +94 to +108
let attributedString = NSMutableAttributedString(string: mainText + pointedText + subText)

attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0,
NSAttributedString.Key.foregroundColor: UIColor.white],
range: NSRange(location: 0, length: mainText.count))

attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.headline1,
NSAttributedString.Key.foregroundColor: DSKitAsset.Colors.purple40.color],
range: NSRange(location: mainText.count, length: pointedText.count))

attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0,
NSAttributedString.Key.foregroundColor: UIColor.white],
range: NSRange(location: mainText.count + pointedText.count, length: subText.count))

currentScoreLabel.attributedText = attributedString
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributedString을 사용하는 부분이 많아서 나중에 모듈을 따로 만들어도 될 것 같네용~

private func bindViewModels() {
let input = ShowAttendanceViewModel.Input()

let input = ShowAttendanceViewModel.Input(viewDidLoad: viewdidload.asDriver(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기서 viewDidload.asDriver 말고 Driver.just를 사용하면 PublishSubject를 사용하지 않아도 됩니다!

Comment on lines +150 to +157
if self.viewModel.sceneType == .scheduledDay {
self.sceneType = .scheduledDay
self.setScheduledData(model)
self.headerScheduleView.updateLayout(.scheduledDay)
} else {
self.sceneType = .unscheduledDay
self.headerScheduleView.updateLayout(.unscheduledDay)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sceneType은 viewModel에만 두고, viewController에서는 연산 프로퍼티로 get만 가능하게 하는 것이 어떨까요?

viewModel과 VC의 sceneType 모두를 관리하는 것보다 viewModel의 sceneType만 사용하는 것이 관리하기에 편하고, SSOT를 지킬 수 있을 것 같아요..!

@devxsby
Copy link
Member Author

devxsby commented Apr 16, 2023

리뷰 반영은 따로 하고 머지 먼저 진행하겠습니다 !! 🙇🏻‍♀️

@devxsby devxsby merged commit 1093ee1 into sopt-makers:develop Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feat 새로운 기능 구현 size/XL 윤수🥚
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 출석 조회하기 API 연결
3 participants