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

[#332] 컨트리뷰터 리팩토링 #333

Merged
merged 4 commits into from
Jun 10, 2024
Merged

Conversation

taehwandev
Copy link
Member

Issue

Overview (Required)

  • 컨트리뷰터 리팩토링 진행
  • Repository에서 연도별 처리를 위한 수정(UseCase 단순 포워딩 하도록 변경)
  • 연도별 모두 노출할 수 있는 데이터 구조화
  • 섹션을 추가하여 연도별 모든 데이터 수정
  • 컨트리뷰터 최신화 작업

@taehwandev taehwandev self-assigned this Jun 10, 2024
val contributors = repository.getContributors(

operator fun invoke(): Flow<Map<Int, List<Contributor>>> =
repository.flowContributors(
Copy link
Member Author

Choose a reason for hiding this comment

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

단일 레포지토리라 하나에서 처리하도록 수정

Copy link

github-actions bot commented Jun 10, 2024

Test Results

20 tests   20 ✅  19s ⏱️
11 suites   0 💤
11 files     0 ❌

Results for commit 57cb172.

♻️ This comment has been updated with latest results.

Copy link
Member

@wisemuji wisemuji 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 8 to 27
val newList = mutableListOf<ContributorsUiState.Contributors.Item>()

// key, value 추가
forEach { (key, values) ->
newList.add(
ContributorsUiState.Contributors.Item.Section(
title = key.toString(),
)
)
values.forEach { item ->
newList.add(
ContributorsUiState.Contributors.Item.User(
id = item.id,
imageUrl = item.imageUrl,
githubUrl = item.githubUrl,
name = item.name,
)
)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

flatMap을 활용해보면 어떨까요?

Suggested change
val newList = mutableListOf<ContributorsUiState.Contributors.Item>()
// key, value 추가
forEach { (key, values) ->
newList.add(
ContributorsUiState.Contributors.Item.Section(
title = key.toString(),
)
)
values.forEach { item ->
newList.add(
ContributorsUiState.Contributors.Item.User(
id = item.id,
imageUrl = item.imageUrl,
githubUrl = item.githubUrl,
name = item.name,
)
)
}
}
val newList = this.flatMap { (key, values) ->
sequenceOf(
ContributorsUiState.Contributors.Item.Section(title = key.toString())
) + values.map { item ->
ContributorsUiState.Contributors.Item.User(
id = item.id,
imageUrl = item.imageUrl,
githubUrl = item.githubUrl,
name = item.name
)
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

오 어떻게 할까 고민하다가 한건데 좋은 방법이네요.

): List<Contributor>

suspend fun getContributorsWithYears(): List<ContributorWithYears>
): Flow<Map<Int, List<Contributor>>>
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

@wisemuji wisemuji left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

@taehwandev taehwandev merged commit f907150 into main Jun 10, 2024
4 checks passed
@taehwandev taehwandev deleted the 2024/feature/ref-contribu branch June 10, 2024 08:55
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