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: 298] 2024년도의 컨트리뷰터 필터링 #305

Merged
merged 19 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.droidknights.app.core.data.repository.api

import com.droidknights.app.core.model.Contributor
import com.droidknights.app.core.model.ContributorWithYears

interface ContributorRepository {

suspend fun getContributors(
owner: String,
name: String,
): List<Contributor>

suspend fun getContributorsWithYears(): List<ContributorWithYears>
}
186 changes: 186 additions & 0 deletions core/data/src/main/assets/contributors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
[
{
"id":28249981,
"name":"laco-dev",
"years":[
2023
]
},
{
"id":32327475,
"name":"wisemuji",
"years":[
2023,
2024
]
},
{
"id":54518925,
"name":"l2hyunwoo",
"years":[
2023
]
},
{
"id":18674395,
"name":"JeonK1",
"years":[
2023
]
},
{
"id":93872496,
"name":"KwakEuiJin",
"years":[
2023
]
},
{
"id":57751515,
"name":"yuuuzzzin",
"years":[
2023
]
},
{
"id":53253298,
"name":"toastmeister1",
"years":[
2023
]
},
{
"id":72238126,
"name":"yjyoon-dev",
"years":[
2023
]
},
{
"id":84944098,
"name":"Cjsghkd",
"years":[
2023
]
},
{
"id":22849063,
"name":"KimReady",
"years":[
2024
]
},
{
"id":2144231,
"name":"taehwandev",
"years":[
2023,
2024
]
},
{
"id":37904970,
"name":"sodp5",
"years":[
2023
]
},
{
"id":51078673,
"name":"JaesungLeee",
"years":[
2023
]
},
{
"id":61337202,
"name":"koreatlwls",
"years":[
2023
]
},
{
"id":44341119,
"name":"malibinYun",
"years":[
2023
]
},
{
"id":1534926,
"name":"Pluu",
"years":[
2023
]
},
{
"id":81838716,
"name":"ParkJong-Hun",
"years":[
2024
]
},
{
"id":92064758,
"name":"theo-taehwan",
"years":[
2024
]
},
{
"id":52663419,
"name":"jeongth9446",
"years":[
2023
]
},
{
"id":4679634,
"name":"kisa002",
"years":[
2023
]
},
{
"id":40175383,
"name":"gowoon-choi",
"years":[
2023
]
},
{
"id":7759511,
"name":"workspace",
"years":[
2023
]
},
{
"id":51016231,
"name":"easyhooon",
"years":[
2024
]
},
{
"id":33443660,
"name":"KwonDae",
"years":[
2023
]
},
{
"id":35232655,
"name":"HamBP",
"years":[
2024
]
},
{
"id":76798309,
"name":"onseok",
"years":[
2023
]
}
]
Copy link
Member

Choose a reason for hiding this comment

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

👍 결국 직접 다 뽑으셨군요. 감사합니다.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.droidknights.app.core.data.api

import com.droidknights.app.core.data.api.model.ContributionYearResponse
import com.droidknights.app.core.data.api.model.SessionResponse
import com.droidknights.app.core.data.api.model.SponsorResponse
import retrofit2.http.GET
Expand All @@ -11,4 +12,7 @@ internal interface GithubRawApi {

@GET("/droidknights/DroidKnightsApp/main/core/data/src/main/assets/sessions.json")
suspend fun getSessions(): List<SessionResponse>

@GET("/droidknights/DroidKnightsApp/main/core/data/src/main/assets/contributors.json")
suspend fun getContributorWithYears(): List<ContributionYearResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.droidknights.app.core.data.api.fake

import android.content.Context
import com.droidknights.app.core.data.api.GithubRawApi
import com.droidknights.app.core.data.api.model.ContributionYearResponse
import com.droidknights.app.core.data.api.model.SessionResponse
import com.droidknights.app.core.data.api.model.SponsorResponse
import kotlinx.serialization.ExperimentalSerializationApi
Expand All @@ -15,6 +16,7 @@ internal class AssetsGithubRawApi(
) : GithubRawApi {
private val sponsors = context.assets.open("sponsors.json")
private val sessions = context.assets.open("sessions.json")
private val contributors = context.assets.open("contributors.json")

override suspend fun getSponsors(): List<SponsorResponse> {
return json.decodeFromStream(sponsors)
Expand All @@ -23,4 +25,8 @@ internal class AssetsGithubRawApi(
override suspend fun getSessions(): List<SessionResponse> {
return json.decodeFromStream(sessions)
}

override suspend fun getContributorWithYears(): List<ContributionYearResponse> {
return json.decodeFromStream(contributors)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.droidknights.app.core.data.api.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ContributionYearResponse(
@SerialName("id") val id: Long,
@SerialName("years") val years: List<Int>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable

@Serializable
internal data class ContributorResponse(
@SerialName("id") val id: Long,
@SerialName("login") val name: String,
@SerialName("avatar_url") val imageUrl: String,
@SerialName("html_url") val githubUrl: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.droidknights.app.core.data.di

import android.content.Context
import com.droidknights.app.core.data.api.GithubApi
import com.droidknights.app.core.data.api.GithubRawApi
import com.droidknights.app.core.data.api.fake.AssetsGithubRawApi
import com.droidknights.app.core.data.repository.DefaultContributorRepository
Expand All @@ -26,11 +27,6 @@ import javax.inject.Singleton
@Module
internal abstract class DataModule {

@Binds
abstract fun bindsContributorRepository(
repository: DefaultContributorRepository,
): ContributorRepository

@Binds
abstract fun bindsSettingsRepository(
repository: DefaultSettingsRepository,
Expand Down Expand Up @@ -60,6 +56,14 @@ internal abstract class DataModule {
): SessionRepository =
DefaultSessionRepository(githubRawApi, sessionDataSource)

@Provides
@Singleton
fun provideContributorRepository(
githubApi: GithubApi,
githubRawApi: AssetsGithubRawApi,
): ContributorRepository =
DefaultContributorRepository(githubApi, githubRawApi)

@Provides
@Singleton
fun provideGithubRawApi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.droidknights.app.core.model.Contributor

internal fun ContributorResponse.toData(): Contributor =
Contributor(
id = id,
name = this.name,
imageUrl = this.imageUrl,
githubUrl = this.githubUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.droidknights.app.core.data.mapper

import com.droidknights.app.core.data.api.model.ContributionYearResponse
import com.droidknights.app.core.model.ContributorWithYears

internal fun ContributionYearResponse.toData(): ContributorWithYears {
return ContributorWithYears(
id = id,
years = years,
)
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package com.droidknights.app.core.data.repository

import com.droidknights.app.core.data.api.GithubApi
import com.droidknights.app.core.data.api.GithubRawApi
import com.droidknights.app.core.data.mapper.toData
import com.droidknights.app.core.data.repository.api.ContributorRepository
import com.droidknights.app.core.model.Contributor
import com.droidknights.app.core.model.ContributorWithYears
import javax.inject.Inject

internal class DefaultContributorRepository @Inject constructor(
private val githubApi: GithubApi,
private val githubRawApi: GithubRawApi
) : ContributorRepository {

override suspend fun getContributors(
owner: String,
name: String,
): List<Contributor> {
return githubApi.getContributors(owner, name)
.map { it.toData() }
return githubApi.getContributors(owner, name).map { it.toData() }
}

override suspend fun getContributorsWithYears(): List<ContributorWithYears> {
return githubRawApi.getContributorWithYears().map { it.toData() }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.droidknights.app.core.data.api.fake

import com.droidknights.app.core.data.api.GithubRawApi
import com.droidknights.app.core.data.api.model.ContributionYearResponse
import com.droidknights.app.core.data.api.model.SessionResponse
import com.droidknights.app.core.data.api.model.SponsorResponse
import kotlinx.serialization.ExperimentalSerializationApi
Expand All @@ -17,6 +18,7 @@ internal class FakeGithubRawApi(
) : GithubRawApi {
private val sponsors = File("src/main/assets/sponsors.json")
private val sessions = File("src/main/assets/sessions.json")
private val contributors = File("src/main/assets/contributors.json")

override suspend fun getSponsors(): List<SponsorResponse> {
return json.decodeFromStream(sponsors.inputStream())
Expand All @@ -25,4 +27,8 @@ internal class FakeGithubRawApi(
override suspend fun getSessions(): List<SessionResponse> {
return json.decodeFromStream(sessions.inputStream())
}

override suspend fun getContributorWithYears(): List<ContributionYearResponse> {
return json.decodeFromStream(contributors.inputStream())
}
}
Loading
Loading