-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add staff list page #557
Merged
Merged
Add staff list page #557
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
11 changes: 11 additions & 0 deletions
11
...Main/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffItemResponseImpl.kt
This file contains 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,11 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class StaffItemResponseImpl( | ||
override val id: String?, | ||
override val name: String?, | ||
override val iconUrl: String?, | ||
override val profileUrl: String? | ||
) : StaffItemResponse |
8 changes: 8 additions & 0 deletions
8
...mmonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffResponseImpl.kt
This file contains 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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class StaffResponseImpl( | ||
override val staffs: List<StaffItemResponseImpl> | ||
) : StaffResponse |
This file contains 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
8 changes: 8 additions & 0 deletions
8
...mmonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffItemResponse.kt
This file contains 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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
interface StaffItemResponse { | ||
val id: String? | ||
val name: String? | ||
val iconUrl: String? | ||
val profileUrl: String? | ||
} |
5 changes: 5 additions & 0 deletions
5
...c/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffResponse.kt
This file contains 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,5 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
interface StaffResponse { | ||
val staffs: List<StaffItemResponse> | ||
} |
This file contains 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 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 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 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
19 changes: 19 additions & 0 deletions
19
data/db-room/src/main/java/io/github/droidkaigi/confsched2019/data/db/dao/StaffDao.kt
This file contains 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,19 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntityImpl | ||
|
||
@Dao | ||
abstract class StaffDao { | ||
@Query("SELECT * FROM staff") | ||
abstract suspend fun allStaffs(): List<StaffEntityImpl> | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
abstract fun insert(staffs: List<StaffEntityImpl>) | ||
|
||
@Query("DELETE FROM staff") | ||
abstract fun deleteAll() | ||
} |
16 changes: 16 additions & 0 deletions
16
...b-room/src/main/java/io/github/droidkaigi/confsched2019/data/db/entity/StaffEntityImpl.kt
This file contains 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,16 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "staff") | ||
class StaffEntityImpl( | ||
@PrimaryKey override var id: String, | ||
@ColumnInfo(name = "staff_name") | ||
override var name: String, | ||
@ColumnInfo(name = "staff_icon_url") | ||
override var iconUrl: String?, | ||
@ColumnInfo(name = "staff_profile_url") | ||
override var profileUrl: String? | ||
) : StaffEntity |
17 changes: 17 additions & 0 deletions
17
.../main/java/io/github/droidkaigi/confsched2019/data/db/entity/mapper/StaffDataMapperExt.kt
This file contains 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,17 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.entity.mapper | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.response.StaffItemResponse | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntityImpl | ||
|
||
fun List<StaffItemResponse>.toStaffEntities(): List<StaffEntityImpl> = map { | ||
it.toStaffEntityImpl() | ||
} | ||
|
||
fun StaffItemResponse.toStaffEntityImpl(): StaffEntityImpl { | ||
return StaffEntityImpl( | ||
id = requireNotNull(id), | ||
name = requireNotNull(name), | ||
iconUrl = iconUrl, | ||
profileUrl = profileUrl | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
data/db/src/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/db/StaffDatabase.kt
This file contains 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,9 @@ | ||
package io.github.droidkaigi.confsched2019.data.db | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.response.StaffResponse | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntity | ||
|
||
interface StaffDatabase { | ||
suspend fun staffs(): List<StaffEntity> | ||
suspend fun save(apiResponse: StaffResponse) | ||
} |
8 changes: 8 additions & 0 deletions
8
...db/src/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/db/entity/StaffEntity.kt
This file contains 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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.entity | ||
|
||
interface StaffEntity { | ||
var id: String | ||
var name: String | ||
var iconUrl: String? | ||
var profileUrl: String? | ||
} |
26 changes: 26 additions & 0 deletions
26
...l/src/main/java/io/github/droidkaigi/confsched2019/data/repository/DataStaffRepository.kt
This file contains 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,26 @@ | ||
package io.github.droidkaigi.confsched2019.data.repository | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.DroidKaigiApi | ||
import io.github.droidkaigi.confsched2019.data.db.StaffDatabase | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntity | ||
import io.github.droidkaigi.confsched2019.model.Staff | ||
import io.github.droidkaigi.confsched2019.model.StaffContents | ||
import javax.inject.Inject | ||
|
||
class DataStaffRepository @Inject constructor( | ||
private val api: DroidKaigiApi, | ||
private val staffDatabase: StaffDatabase | ||
) : StaffRepository { | ||
override suspend fun staffContents() = StaffContents(staffs()) | ||
|
||
override suspend fun refresh() { | ||
val response = api.getStaffs() | ||
staffDatabase.save(response) | ||
} | ||
|
||
private suspend fun staffs() = staffDatabase | ||
.staffs() | ||
.map { it.toStaff() } | ||
} | ||
|
||
private fun StaffEntity.toStaff(): Staff = Staff(id, name, iconUrl, profileUrl) |
This file contains 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 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
8 changes: 8 additions & 0 deletions
8
...c/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/repository/StaffRepository.kt
This file contains 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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.repository | ||
|
||
import io.github.droidkaigi.confsched2019.model.StaffContents | ||
|
||
interface StaffRepository { | ||
suspend fun staffContents(): StaffContents | ||
suspend fun refresh() | ||
} |
This file contains 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
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.
Maybe we should use "deleteAll()" before insert(). Because If someone quits the staff for some reason, it seems to remain. 👀
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.
That's a good catch 💯