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

👍 participants 構造変更に伴う対応 #127

Merged
merged 1 commit into from
Dec 6, 2023
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
Expand Up @@ -4,10 +4,10 @@ package club.nito.core.model.participant
* 参加情報
* @param scheduleId スケジュールID
* @param userId 参加ユーザーID
* @param comment コメント
* @param status 参加状況
*/
public data class Participant(
val scheduleId: String,
val userId: String,
val comment: String,
val status: ParticipantStatus,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package club.nito.core.model.participant

/**
* 参加状況
*/
public enum class ParticipantStatus {
/**
* 未定
*/
PENDING,

/**
* 出席
*/
ATTENDANCE,

/**
* 欠席
*/
ABSENCE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class SupabaseParticipantRemoteDataSource(
filter {
and {
eq("schedule_id", scheduleId)
exact("deleted_at", null)
}
}
}
Expand All @@ -35,7 +34,6 @@ public class SupabaseParticipantRemoteDataSource(
filter {
and {
isIn("schedule_id", scheduleIds)
exact("deleted_at", null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import kotlinx.serialization.Serializable
internal data class NetworkParticipant(
val scheduleId: String,
val userId: String,
val comment: String,
val status: NetworkParticipantStatus,
) {
fun toParticipant() = Participant(
scheduleId = scheduleId,
userId = userId,
comment = comment,
status = status.toParticipantStatus(),
)
}

internal fun createFakeNetworkParticipant(
scheduleId: String = "bbe00d24-d840-460d-a127-f23f9e472cc6",
userId: String = "bbe00d24-d840-460d-a127-f23f9e472cc6",
comment: String = "コメント",
status: NetworkParticipantStatus = NetworkParticipantStatus.ATTENDANCE,
) = NetworkParticipant(
scheduleId = scheduleId,
userId = userId,
comment = comment,
status = status,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package club.nito.core.network.participation.model

import club.nito.core.model.participant.ParticipantStatus
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* 参加状況
*/
@Serializable
internal enum class NetworkParticipantStatus {
/**
* 未定
*/
@SerialName(value = "pending")
PENDING,

/**
* 出席
*/
@SerialName(value = "attendance")
ATTENDANCE,

/**
* 欠席
*/
@SerialName(value = "absence")
ABSENCE;

fun toParticipantStatus(): ParticipantStatus =
when (this) {
PENDING -> ParticipantStatus.PENDING
ATTENDANCE -> ParticipantStatus.ATTENDANCE
ABSENCE -> ParticipantStatus.ABSENCE
}
}