From 7f7262b143834f873aa42ce4e73a8942a28e1424 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 20:44:56 +0900 Subject: [PATCH 1/5] =?UTF-8?q?:bug:=20=E3=83=87=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=8C=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/network/schedule/SupabaseScheduleRemoteDataSource.kt | 2 +- .../club/nito/core/network/schedule/model/NetworkSchedule.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/SupabaseScheduleRemoteDataSource.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/SupabaseScheduleRemoteDataSource.kt index 4c1d818d..a361df92 100644 --- a/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/SupabaseScheduleRemoteDataSource.kt +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/SupabaseScheduleRemoteDataSource.kt @@ -49,7 +49,7 @@ public class SupabaseScheduleRemoteDataSource( exact(Column.DELETED_AT.columnName, null) } } - .decodeSingle() + .decodeAs() .let(NetworkSchedule::toSchedule) } } diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/model/NetworkSchedule.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/model/NetworkSchedule.kt index a1c1369c..69df6862 100644 --- a/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/model/NetworkSchedule.kt +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/schedule/model/NetworkSchedule.kt @@ -20,7 +20,7 @@ internal data class NetworkSchedule( metAt = metAt, venueId = venueId, meetId = meetId, - description = description, + description = description.replace("\\n", "\n"), ) } From 99d55284100983028dd1bc11c5b9a47ab7256c37 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 20:45:13 +0900 Subject: [PATCH 2/5] =?UTF-8?q?:sparkles:=20=E5=A0=B4=E6=89=80=E3=81=AE?= =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/club/nito/core/model/place/Place.kt | 17 +++++++++++++++++ .../club/nito/core/model/place/PlaceId.kt | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 core/model/src/commonMain/kotlin/club/nito/core/model/place/Place.kt create mode 100644 core/model/src/commonMain/kotlin/club/nito/core/model/place/PlaceId.kt diff --git a/core/model/src/commonMain/kotlin/club/nito/core/model/place/Place.kt b/core/model/src/commonMain/kotlin/club/nito/core/model/place/Place.kt new file mode 100644 index 00000000..53429b30 --- /dev/null +++ b/core/model/src/commonMain/kotlin/club/nito/core/model/place/Place.kt @@ -0,0 +1,17 @@ +package club.nito.core.model.place + +/** + * 場所 + * @param id ID + * @param name 名前 + * @param description 説明文 + * @param mapUrl 地図URL + * @param imageUrl 画像URL + */ +public data class Place( + val id: PlaceId, + val name: String, + val description: String, + val mapUrl: String, + val imageUrl: String, +) diff --git a/core/model/src/commonMain/kotlin/club/nito/core/model/place/PlaceId.kt b/core/model/src/commonMain/kotlin/club/nito/core/model/place/PlaceId.kt new file mode 100644 index 00000000..2f599e52 --- /dev/null +++ b/core/model/src/commonMain/kotlin/club/nito/core/model/place/PlaceId.kt @@ -0,0 +1,6 @@ +package club.nito.core.model.place + +/** + * 場所ID + */ +public typealias PlaceId = String From 99bb4bb04ef05f45c77b20cc2eb752e457c36573 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 20:45:30 +0900 Subject: [PATCH 3/5] =?UTF-8?q?:sparkles:=20=E5=A0=B4=E6=89=80=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=BD=E3=83=BC=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/di/FakeRemoteDataSourceModule.kt | 3 ++ .../core/network/di/RemoteDataSourceModule.kt | 5 +++ .../place/FakePlaceRemoteDataSource.kt | 14 ++++++ .../network/place/PlaceRemoteDataSource.kt | 15 +++++++ .../place/SupabasePlaceRemoteDataSource.kt | 32 ++++++++++++++ .../core/network/place/model/NetworkPlace.kt | 43 +++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 core/network/src/commonMain/kotlin/club/nito/core/network/place/FakePlaceRemoteDataSource.kt create mode 100644 core/network/src/commonMain/kotlin/club/nito/core/network/place/PlaceRemoteDataSource.kt create mode 100644 core/network/src/commonMain/kotlin/club/nito/core/network/place/SupabasePlaceRemoteDataSource.kt create mode 100644 core/network/src/commonMain/kotlin/club/nito/core/network/place/model/NetworkPlace.kt diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/di/FakeRemoteDataSourceModule.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/di/FakeRemoteDataSourceModule.kt index 7f5b27ae..16b03b83 100644 --- a/core/network/src/commonMain/kotlin/club/nito/core/network/di/FakeRemoteDataSourceModule.kt +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/di/FakeRemoteDataSourceModule.kt @@ -4,6 +4,8 @@ import club.nito.core.network.auth.AuthRemoteDataSource import club.nito.core.network.auth.FakeAuthRemoteDataSource import club.nito.core.network.participation.FakeParticipantRemoteDataSource import club.nito.core.network.participation.ParticipantRemoteDataSource +import club.nito.core.network.place.FakePlaceRemoteDataSource +import club.nito.core.network.place.PlaceRemoteDataSource import club.nito.core.network.schedule.FakeScheduleRemoteDataSource import club.nito.core.network.schedule.ScheduleRemoteDataSource import club.nito.core.network.user.FakeUserRemoteDataSource @@ -23,4 +25,5 @@ public val fakeRemoteDataSourceModule: Module = module { single { FakeScheduleRemoteDataSource } single { FakeParticipantRemoteDataSource } single { FakeUserRemoteDataSource } + single { FakePlaceRemoteDataSource } } diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/di/RemoteDataSourceModule.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/di/RemoteDataSourceModule.kt index 12b89e87..7bb851a9 100644 --- a/core/network/src/commonMain/kotlin/club/nito/core/network/di/RemoteDataSourceModule.kt +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/di/RemoteDataSourceModule.kt @@ -5,11 +5,15 @@ import club.nito.core.network.auth.AuthRemoteDataSource import club.nito.core.network.auth.SupabaseAuthRemoteDataSource import club.nito.core.network.participation.ParticipantRemoteDataSource import club.nito.core.network.participation.SupabaseParticipantRemoteDataSource +import club.nito.core.network.place.PlaceRemoteDataSource +import club.nito.core.network.place.SupabasePlaceRemoteDataSource import club.nito.core.network.schedule.ScheduleRemoteDataSource import club.nito.core.network.schedule.SupabaseScheduleRemoteDataSource import club.nito.core.network.user.SupabaseUserRemoteDataSource import club.nito.core.network.user.UserRemoteDataSource import org.koin.core.module.Module +import org.koin.core.module.dsl.singleOf +import org.koin.dsl.bind import org.koin.dsl.module public val remoteDataSourceModule: Module = module { @@ -41,4 +45,5 @@ public val remoteDataSourceModule: Module = module { client = get(), ) } + singleOf(::SupabasePlaceRemoteDataSource) bind PlaceRemoteDataSource::class } diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/place/FakePlaceRemoteDataSource.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/place/FakePlaceRemoteDataSource.kt new file mode 100644 index 00000000..5bbb4bc0 --- /dev/null +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/place/FakePlaceRemoteDataSource.kt @@ -0,0 +1,14 @@ +package club.nito.core.network.place + +import club.nito.core.model.place.Place +import club.nito.core.model.place.PlaceId +import club.nito.core.network.place.model.NetworkPlace +import club.nito.core.network.place.model.createFakeNetworkPlace + +public data object FakePlaceRemoteDataSource : PlaceRemoteDataSource { + override suspend fun fetchPlaceList(idList: List): List = idList.map { id -> + createFakeNetworkPlace( + id = id, + ).let(NetworkPlace::toPlace) + } +} diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/place/PlaceRemoteDataSource.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/place/PlaceRemoteDataSource.kt new file mode 100644 index 00000000..6fc5df85 --- /dev/null +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/place/PlaceRemoteDataSource.kt @@ -0,0 +1,15 @@ +package club.nito.core.network.place + +import club.nito.core.model.place.Place +import club.nito.core.model.place.PlaceId + +/** + * 場所リモートデータソース + */ +public sealed interface PlaceRemoteDataSource { + /** + * リモートから場所を取得する + * @param idList 取得する場所のID + */ + public suspend fun fetchPlaceList(idList: List): List +} diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/place/SupabasePlaceRemoteDataSource.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/place/SupabasePlaceRemoteDataSource.kt new file mode 100644 index 00000000..1bff3d3a --- /dev/null +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/place/SupabasePlaceRemoteDataSource.kt @@ -0,0 +1,32 @@ +package club.nito.core.network.place + +import club.nito.core.model.place.Place +import club.nito.core.model.place.PlaceId +import club.nito.core.network.NetworkService +import club.nito.core.network.place.model.NetworkPlace +import io.github.jan.supabase.SupabaseClient +import io.github.jan.supabase.postgrest.postgrest + +private enum class Column(val columnName: String) { + ID(columnName = "id"), + DELETED_AT(columnName = "deleted_at"), +} + +public class SupabasePlaceRemoteDataSource( + private val networkService: NetworkService, + private val client: SupabaseClient, +) : PlaceRemoteDataSource { + private val postgrest = client.postgrest["places"] + + override suspend fun fetchPlaceList(idList: List): List = networkService { + postgrest + .select { + filter { + isIn(Column.ID.columnName, idList) + exact(Column.DELETED_AT.columnName, null) + } + } + .decodeList() + .map(NetworkPlace::toPlace) + } +} diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/place/model/NetworkPlace.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/place/model/NetworkPlace.kt new file mode 100644 index 00000000..db70c923 --- /dev/null +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/place/model/NetworkPlace.kt @@ -0,0 +1,43 @@ +package club.nito.core.network.place.model + +import club.nito.core.model.place.Place +import kotlinx.serialization.Serializable + +/** + * 場所 + * @param id ID + * @param name 名前 + * @param description 説明文 + * @param mapUrl 地図URL + * @param imageUrl 画像URL + */ +@Serializable +public data class NetworkPlace internal constructor( + val id: String, + val name: String, + val description: String, + val mapUrl: String, + val imageUrl: String, +) { + internal fun toPlace() = Place( + id = id, + name = name, + description = description.replace("\\n", "\n"), + mapUrl = mapUrl, + imageUrl = imageUrl, + ) +} + +internal fun createFakeNetworkPlace( + id: String = "bbe00d24-d840-460d-a127-f23f9e472cc6", + name: String = "レイクタウン", + description: String = "レイクタウンは、埼玉県越谷市にある複合商業施設である。2008年(平成20年)3月14日に開業した。運営は三井不動産商業マネジメントが行っている。", + mapUrl: String = "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3239.919508821314!2d139.790403315258!3d35.89174898014363!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6018f3b0b0b0b0b1%3A0x1b0b0b0b0b0b0b0b!2z44CSMzUwLTAwMjQg5p2x5Lqs6YO95riv5Yy65Y2X6YCa5L2c5a2Q5bGx77yR5LiB55uu77yR77yR4oiS77yR!5e0!3m2!1sja!2sjp!4v1629788517009!5m2!1sja!2sjp", + imageUrl: String = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Laketown_outside.jpg/1200px-Laketown_outside.jpg", +) = NetworkPlace( + id = id, + name = name, + description = description, + mapUrl = mapUrl, + imageUrl = imageUrl, +) From d58a4d445b6d2382bdb53d30ae43240eb737216f Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 20:45:51 +0900 Subject: [PATCH 4/5] =?UTF-8?q?:sparkles:=20=E5=A0=B4=E6=89=80=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=9D=E3=82=B8=E3=83=88=E3=83=AA=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/nito/core/data/DefaultPlaceRepository.kt | 13 +++++++++++++ .../kotlin/club/nito/core/data/PlaceRepository.kt | 15 +++++++++++++++ .../kotlin/club/nito/core/data/di/DataModule.kt | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 core/data/src/commonMain/kotlin/club/nito/core/data/DefaultPlaceRepository.kt create mode 100644 core/data/src/commonMain/kotlin/club/nito/core/data/PlaceRepository.kt diff --git a/core/data/src/commonMain/kotlin/club/nito/core/data/DefaultPlaceRepository.kt b/core/data/src/commonMain/kotlin/club/nito/core/data/DefaultPlaceRepository.kt new file mode 100644 index 00000000..bbbb87cf --- /dev/null +++ b/core/data/src/commonMain/kotlin/club/nito/core/data/DefaultPlaceRepository.kt @@ -0,0 +1,13 @@ +package club.nito.core.data + +import club.nito.core.model.place.Place +import club.nito.core.model.place.PlaceId +import club.nito.core.network.place.PlaceRemoteDataSource + +public class DefaultPlaceRepository( + private val remoteDataSource: PlaceRemoteDataSource, +) : PlaceRepository { + override suspend fun fetchPlaceList(vararg ids: PlaceId): List { + return remoteDataSource.fetchPlaceList(ids.toList()) + } +} diff --git a/core/data/src/commonMain/kotlin/club/nito/core/data/PlaceRepository.kt b/core/data/src/commonMain/kotlin/club/nito/core/data/PlaceRepository.kt new file mode 100644 index 00000000..785bb415 --- /dev/null +++ b/core/data/src/commonMain/kotlin/club/nito/core/data/PlaceRepository.kt @@ -0,0 +1,15 @@ +package club.nito.core.data + +import club.nito.core.model.place.Place +import club.nito.core.model.place.PlaceId + +/** + * 場所に関するリポジトリ + */ +public sealed interface PlaceRepository { + /** + * 場所を取得する + * @param ids 取得する場所のID + */ + public suspend fun fetchPlaceList(vararg ids: PlaceId): List +} diff --git a/core/data/src/commonMain/kotlin/club/nito/core/data/di/DataModule.kt b/core/data/src/commonMain/kotlin/club/nito/core/data/di/DataModule.kt index 2fe2efdb..cb5b3652 100644 --- a/core/data/src/commonMain/kotlin/club/nito/core/data/di/DataModule.kt +++ b/core/data/src/commonMain/kotlin/club/nito/core/data/di/DataModule.kt @@ -3,9 +3,11 @@ package club.nito.core.data.di import club.nito.core.data.AuthRepository import club.nito.core.data.DefaultAuthRepository import club.nito.core.data.DefaultParticipantRepository +import club.nito.core.data.DefaultPlaceRepository import club.nito.core.data.DefaultUserRepository import club.nito.core.data.OfflineFirstScheduleRepository import club.nito.core.data.ParticipantRepository +import club.nito.core.data.PlaceRepository import club.nito.core.data.ScheduleRepository import club.nito.core.data.UserRepository import org.koin.core.module.Module @@ -18,4 +20,5 @@ public val dataModule: Module = module { singleOf(::OfflineFirstScheduleRepository) bind ScheduleRepository::class singleOf(::DefaultParticipantRepository) bind ParticipantRepository::class singleOf(::DefaultUserRepository) bind UserRepository::class + singleOf(::DefaultPlaceRepository) bind PlaceRepository::class } From 631cba0ec1c03d14964a5f0ec29e1164b89025c2 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 20:46:21 +0900 Subject: [PATCH 5/5] =?UTF-8?q?:+1:=20=E5=90=84=20UseCase=20=E3=81=A7?= =?UTF-8?q?=E5=A0=B4=E6=89=80=E3=81=AE=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/FetchParticipantScheduleByIdUseCase.kt | 10 ++++++++-- .../domain/GetParticipantScheduleListUseCase.kt | 14 +++++++++++--- .../nito/core/domain/GetRecentScheduleUseCase.kt | 12 +++++++++--- .../nito/core/domain/model/ParticipantSchedule.kt | 5 +++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/core/domain/src/commonMain/kotlin/club/nito/core/domain/FetchParticipantScheduleByIdUseCase.kt b/core/domain/src/commonMain/kotlin/club/nito/core/domain/FetchParticipantScheduleByIdUseCase.kt index 29f500bd..5a209d46 100644 --- a/core/domain/src/commonMain/kotlin/club/nito/core/domain/FetchParticipantScheduleByIdUseCase.kt +++ b/core/domain/src/commonMain/kotlin/club/nito/core/domain/FetchParticipantScheduleByIdUseCase.kt @@ -1,6 +1,7 @@ package club.nito.core.domain import club.nito.core.data.ParticipantRepository +import club.nito.core.data.PlaceRepository import club.nito.core.data.ScheduleRepository import club.nito.core.data.UserRepository import club.nito.core.domain.extension.toUserIdList @@ -8,6 +9,7 @@ import club.nito.core.domain.model.ParticipantSchedule import club.nito.core.model.FetchSingleContentResult import club.nito.core.model.UserProfile import club.nito.core.model.participant.Participant +import club.nito.core.model.place.Place import club.nito.core.model.schedule.Schedule import club.nito.core.model.schedule.ScheduleId import club.nito.core.model.toNitoError @@ -22,6 +24,7 @@ public sealed interface FetchParticipantScheduleByIdUseCase { public class FetchParticipantScheduleByIdExecutor( private val scheduleRepository: ScheduleRepository, private val participantRepository: ParticipantRepository, + private val placeRepository: PlaceRepository, private val userRepository: UserRepository, ) : FetchParticipantScheduleByIdUseCase { override suspend fun invoke(id: ScheduleId): FetchSingleContentResult { @@ -33,10 +36,12 @@ public class FetchParticipantScheduleByIdExecutor( val participants = participantRepository.getParticipants(id) val profiles = userRepository.getProfiles(userIds = participants.toUserIdList()) + val places = placeRepository.fetchPlaceList(schedule.venueId, schedule.meetId) val participantSchedule = transformToParticipantSchedule( schedule = schedule, participants = participants, userProfiles = profiles, + places = places, ) return FetchSingleContentResult.Success(participantSchedule) @@ -46,6 +51,7 @@ public class FetchParticipantScheduleByIdExecutor( schedule: Schedule, participants: List, userProfiles: List, + places: List, ): ParticipantSchedule { val scheduleParticipants = participants.filter { it.scheduleId == schedule.id } val scheduleParticipantProfiles = userProfiles.filter { profile -> @@ -56,8 +62,8 @@ public class FetchParticipantScheduleByIdExecutor( id = schedule.id, scheduledAt = schedule.scheduledAt, metAt = schedule.metAt, - venueId = schedule.venueId, - meetId = schedule.meetId, + venue = places.first { it.id == schedule.venueId }, + meet = places.first { it.id == schedule.meetId }, description = schedule.description, participants = scheduleParticipantProfiles, ) diff --git a/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetParticipantScheduleListUseCase.kt b/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetParticipantScheduleListUseCase.kt index 745f7281..972b0df1 100644 --- a/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetParticipantScheduleListUseCase.kt +++ b/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetParticipantScheduleListUseCase.kt @@ -1,13 +1,15 @@ package club.nito.core.domain import club.nito.core.data.ParticipantRepository +import club.nito.core.data.PlaceRepository import club.nito.core.data.ScheduleRepository import club.nito.core.data.UserRepository import club.nito.core.domain.model.ParticipantSchedule import club.nito.core.model.FetchMultipleContentResult -import club.nito.core.model.schedule.Schedule import club.nito.core.model.UserProfile import club.nito.core.model.participant.Participant +import club.nito.core.model.place.Place +import club.nito.core.model.schedule.Schedule import club.nito.core.model.toNitoError import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -22,6 +24,7 @@ public sealed interface GetParticipantScheduleListUseCase { public class GetParticipantScheduleListExecutor( private val scheduleRepository: ScheduleRepository, private val participantRepository: ParticipantRepository, + private val placeRepository: PlaceRepository, private val userRepository: UserRepository, ) : GetParticipantScheduleListUseCase { override fun invoke(): Flow> = flow { @@ -40,10 +43,14 @@ public class GetParticipantScheduleListExecutor( val participants = participantRepository.getParticipants(scheduleIds = schedules.map { it.id }) val profiles = userRepository.getProfiles(userIds = participants.distinctBy { it.userId }.map { it.userId }) + val placeIds = (schedules.map { it.meetId } + schedules.map { it.venueId }).distinct() + val places = placeRepository.fetchPlaceList(*placeIds.toTypedArray()) + val participantScheduleList = transformToParticipantScheduleList( schedules = schedules, participants = participants, userProfiles = profiles, + places = places, ) emit(FetchMultipleContentResult.Success(participantScheduleList)) @@ -53,6 +60,7 @@ public class GetParticipantScheduleListExecutor( schedules: List, participants: List, userProfiles: List, + places: List, ): List = schedules.map { schedule -> val scheduleParticipants = participants.filter { it.scheduleId == schedule.id } val scheduleParticipantProfiles = userProfiles.filter { profile -> @@ -63,8 +71,8 @@ public class GetParticipantScheduleListExecutor( id = schedule.id, scheduledAt = schedule.scheduledAt, metAt = schedule.metAt, - venueId = schedule.venueId, - meetId = schedule.meetId, + venue = places.first { it.id == schedule.venueId }, + meet = places.first { it.id == schedule.meetId }, description = schedule.description, participants = scheduleParticipantProfiles, ) diff --git a/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetRecentScheduleUseCase.kt b/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetRecentScheduleUseCase.kt index 3973aa33..c320a283 100644 --- a/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetRecentScheduleUseCase.kt +++ b/core/domain/src/commonMain/kotlin/club/nito/core/domain/GetRecentScheduleUseCase.kt @@ -1,13 +1,15 @@ package club.nito.core.domain import club.nito.core.data.ParticipantRepository +import club.nito.core.data.PlaceRepository import club.nito.core.data.ScheduleRepository import club.nito.core.data.UserRepository import club.nito.core.domain.model.ParticipantSchedule import club.nito.core.model.FetchSingleContentResult import club.nito.core.model.Order -import club.nito.core.model.schedule.Schedule import club.nito.core.model.UserProfile +import club.nito.core.model.place.Place +import club.nito.core.model.schedule.Schedule import club.nito.core.model.toNitoError import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -23,6 +25,7 @@ public sealed interface GetRecentScheduleUseCase { public class GetRecentScheduleExecutor( private val scheduleRepository: ScheduleRepository, private val participantRepository: ParticipantRepository, + private val placeRepository: PlaceRepository, private val userRepository: UserRepository, ) : GetRecentScheduleUseCase { override fun invoke(): Flow> = flow { @@ -46,10 +49,12 @@ public class GetRecentScheduleExecutor( val participants = participantRepository.getParticipants(scheduleId = schedule.id) val userProfiles = userRepository.getProfiles(userIds = participants.map { it.userId }) + val places = placeRepository.fetchPlaceList(schedule.venueId, schedule.meetId) val participantSchedule = transformToParticipantSchedule( schedule = schedule, userProfiles = userProfiles, + places = places, ) emit(FetchSingleContentResult.Success(participantSchedule)) @@ -58,13 +63,14 @@ public class GetRecentScheduleExecutor( private fun transformToParticipantSchedule( schedule: Schedule, userProfiles: List, + places: List, ): ParticipantSchedule { return ParticipantSchedule( id = schedule.id, scheduledAt = schedule.scheduledAt, metAt = schedule.metAt, - venueId = schedule.venueId, - meetId = schedule.meetId, + venue = places.first { it.id == schedule.venueId }, + meet = places.first { it.id == schedule.meetId }, description = schedule.description, participants = userProfiles, ) diff --git a/core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.kt b/core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.kt index d639a50c..aee9f487 100644 --- a/core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.kt +++ b/core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.kt @@ -1,6 +1,7 @@ package club.nito.core.domain.model import club.nito.core.model.UserProfile +import club.nito.core.model.place.Place import club.nito.core.model.schedule.ScheduleId import kotlinx.datetime.Instant @@ -8,8 +9,8 @@ public data class ParticipantSchedule( val id: ScheduleId, val scheduledAt: Instant, val metAt: Instant, - val venueId: String, - val meetId: String, + val venue: Place, + val meet: Place, val description: String, val participants: List, )