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

출석 정보 가져오기 구현 #1015

Conversation

giovannijunseokim
Copy link
Contributor

@giovannijunseokim giovannijunseokim commented Jan 4, 2025

What is this issue?

출석 정보를 가져오는 API를 연결하고 도메인으로 전환, Ui에 반영까지 작업하였습니다.

Image

추후 세션을 만들어서 테스트 해보고 수정 필요하면 수정해서 다시 올리겠슴다

Reference

  • [x]

* Attendance screen compose setting (#676)

* feat: implement NewAttendanceActivity

* feat: implement NewAttendanceViewModel

* chore: add compose-lifecycle dependency

* feat: define AttendanceAction

* feat: implement screens

* feat: use SoptTheme in designsystem

* chore: data class -> class로 변경

* chore: 람다 프로퍼티 이름 명시

* chore: SoptTheme darkTheme 기본값 사용

* chore: 필요없는 함수 제거

* chore: 구현 안 된 함수에 TODO 삽입

* chore: 동작하지 않는 Preview 제거

* chore: AttendanceAction 내 뷰모델 참조 제거

* chore: code format 변경

* chore: make stamp design system internal

* chore: extract string resource

* feat: implement AttendanceCodeCard

* feat: implement AttendanceCodeCardList

* chore: change logic

* feat: implement AttendanceCodeDialog

* feat: implement attendance button

* chore: string resource 추출

* chore: change parameter List to ImmutableList

* chore: reformat codee
@giovannijunseokim giovannijunseokim requested a review from a team as a code owner January 4, 2025 16:16
Copy link

height bot commented Jan 4, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@giovannijunseokim giovannijunseokim changed the title 출석 정보 가져오기 출석 정보 가져오기 구현 Jan 4, 2025

import java.time.LocalDateTime

data class AttendanceInfo(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data class AttendanceInfo(
data class Attendance(

로 줄이는건 어떨까요? Info는 불필요한 단어인 것 같아서요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ㅇㅈ합니다. 감사합니다!

Copy link
Contributor Author

@giovannijunseokim giovannijunseokim Jan 5, 2025

Choose a reason for hiding this comment

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

이름 변경했습니다! 839f758
추가적으로 SessionInfo도 Session으로 변경했습니다! 12b0a97

is AttendanceInfo.AttendanceDayType.NoAttendance -> {
val sessionInfo = attendanceInfo.attendanceDayType.sessionInfo
AttendanceDayType.Event(
eventDate = "${sessionInfo.sessionStartTime} - ${sessionInfo.sessionEndTime}",
Copy link
Member

Choose a reason for hiding this comment

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

LocalDateTime.parse로 파싱한걸 그대로 string으로 변환되면 2025-01-01T00:00:000 이런식으로 출력될 것 같은데, 혹시 어떻게 출력되는지 알 수 있을까요?

Copy link
Contributor Author

@giovannijunseokim giovannijunseokim Jan 5, 2025

Choose a reason for hiding this comment

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

요 부분 까먹고있다가 확인해서 작업했습니다! a1d1134 -> bac1a01
Kotlin Playground에서 테스트 해봤고, 잘 동작하는 것 같아요 ~!

Comment on lines 59 to 60
val firstAttendanceResponse: SoptEventResponse.AttendanceResponse? = soptEventResponse.attendances.firstOrNull()
val secondAttendanceResponse: SoptEventResponse.AttendanceResponse? = soptEventResponse.attendances.lastOrNull()
Copy link
Member

Choose a reason for hiding this comment

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

이거 lastOrNull로 가도 괜찮을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

예시 보니깐 attendances를 반드시 2개로 주긴 하더라구요. 더 좋은 방법이 있는지 생각해보겠습니다. 감사합니다!

Copy link
Contributor Author

@giovannijunseokim giovannijunseokim Jan 8, 2025

Choose a reason for hiding this comment

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

저렇게 코드를 작성했을 때 물론 현재는 2개가 오지만, 만약 한 개만 오도록 변경될 경우 문제가 발생할 수 있다는 것을 파악했습니다.
(한 개만 올 경우, firstAttendanceResponsesecondAttendanceResponse가 같아집니다.)

따라서 getOrNull를 사용하여 의도된 위치의 값만 가져오도록 수정했습니다. da67e2e

Copy link
Member

@l2hyunwoo l2hyunwoo left a comment

Choose a reason for hiding this comment

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

한번 확인해주시고 문제 없으면 바로 머지 갑시다 👍🏻 고생했어요

Copy link
Member

@l2hyunwoo l2hyunwoo left a comment

Choose a reason for hiding this comment

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

고생했습니다 👍


sealed interface FetchAttendanceCurrentRoundResult {
data class Success(val round: Int?) : FetchAttendanceCurrentRoundResult
data class Failure(val errorMessage: String?) : FetchAttendanceCurrentRoundResult
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data class Failure(val errorMessage: String?) : FetchAttendanceCurrentRoundResult
data class Failure(val error: Throwable) : FetchAttendanceCurrentRoundResult

사용처에서 선택권주는 것도 나쁘지 않을듯?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

음 그렇게 할 경우 뷰모델에서 Json을 뜯어서 에러 메시지를 얻어오거나, HttpException에 대해 처리해야 하는 경우가 생기게 될 것 같아요.

Repository에서는 데이터를 ViewModel로 전달하기 전에 도메인 모델의 순수한 형태로 내려주고, ViewModel에서는 Throwable의 처리보다는 View에서 보여줄 데이터에 집중하고 싶은데 어떻게 하는 것이 좋을까요?

PreviewParameterProvider<Float>

private val Float.prettyString: String
Copy link
Member

Choose a reason for hiding this comment

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

👍

);

companion object {
fun of(
Copy link
Member

Choose a reason for hiding this comment

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

도의적으로 함수로 따로빼서 만들어주는게 좋지 않을까? 도메인 로직에 굉장히 중요한 함수여서 좀 주목받을 수 있게(?)

Copy link
Member

Choose a reason for hiding this comment

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

얘는 테스트 코드 작성해라

Copy link
Contributor Author

@giovannijunseokim giovannijunseokim Jan 9, 2025

Choose a reason for hiding this comment

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

함수를 따로 뺄까 생각하다가, FinalAttendance(최종 출석)가 어떻게 결정되는지 확인하기 위해서는 우선 FinalAttendance 클래스로 찾아갈 것이라 예상했습니다.

따라서 companion object 내부에 존재하는 형태는 유지한 채, 함수명을 calculateFinalAttendance로 바꿔보았습니다.

4282b33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

추가적으로, 테스트도 작성해 보았습니다.
다만 테스트 작성이 처음이라, 어떻게 작성하는 것이 좋을지 고민되어 결국 최대한 모든 상황을 테스트하는 방식으로 작성해 보았습니다.

da8fa44

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3X3으로 9가지 테스트를 수행하여 모든 케이스를 커버하도록 수정해보았습니다.
78929d0

@giovannijunseokim giovannijunseokim merged commit 816168f into feature/refactor-attendance-screen Jan 10, 2025
@giovannijunseokim giovannijunseokim deleted the implement-fetch-attendance-info branch January 10, 2025 10:41
giovannijunseokim added a commit that referenced this pull request Jan 28, 2025
* AttendanceCodeDialog 구현 (#852)

* Attendance screen compose setting (#676)

* feat: implement NewAttendanceActivity

* feat: implement NewAttendanceViewModel

* chore: add compose-lifecycle dependency

* feat: define AttendanceAction

* feat: implement screens

* feat: use SoptTheme in designsystem

* chore: data class -> class로 변경

* chore: 람다 프로퍼티 이름 명시

* chore: SoptTheme darkTheme 기본값 사용

* chore: 필요없는 함수 제거

* chore: 구현 안 된 함수에 TODO 삽입

* chore: 동작하지 않는 Preview 제거

* chore: AttendanceAction 내 뷰모델 참조 제거

* chore: code format 변경

* chore: make stamp design system internal

* chore: extract string resource

* feat: implement AttendanceCodeCard

* feat: implement AttendanceCodeCardList

* chore: change logic

* feat: implement AttendanceCodeDialog

* feat: implement attendance button

* chore: string resource 추출

* chore: change parameter List to ImmutableList

* chore: reformat codee

* feat: implement domain models

* feat: implement Repository

* chore: remove unnecessary code

* chore: change attendanceScore to Float

* chore: reflect type name changed

* chore: remove totalCount from parameters

* feat: add action onClickRefresh

* feat: implement bindDefaultAttendanceRepository

* chore: add background at route

* chore: change button radius

* chore: reformat code

* feat: implement Domain Model to UiModel

* chore: rename AttendanceInfo to Attendance

* chore: rename SessionInfo

* feat: format LocalDateTime

* chore: use DateTimeFormatter

* chore: use getOrNull

* chore: don't use it

* feat: implement AttendanceMapper

* chore: remove duplicate code

* chore: change to Extension

* chore: change parameter name

* chore: change code clear

* chore: make code clear

* chore: separate package

* chore: change function name

* feat: implement FinalAttendanceTest

* chore: remove duplicate tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants