-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ ID を元にスケジュールを取得するユースケースを追加 #117
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 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
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
65 changes: 65 additions & 0 deletions
65
...domain/src/commonMain/kotlin/club/nito/core/domain/FetchParticipantScheduleByIdUseCase.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,65 @@ | ||
package club.nito.core.domain | ||
|
||
import club.nito.core.data.ParticipantRepository | ||
import club.nito.core.data.ScheduleRepository | ||
import club.nito.core.data.UserRepository | ||
import club.nito.core.domain.extension.toUserIdList | ||
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.schedule.Schedule | ||
import club.nito.core.model.schedule.ScheduleId | ||
import club.nito.core.model.toNitoError | ||
|
||
/** | ||
* ID を元にスケジュールを取得するユースケース | ||
*/ | ||
public sealed interface FetchParticipantScheduleByIdUseCase { | ||
public suspend operator fun invoke(id: ScheduleId): FetchSingleContentResult<ParticipantSchedule> | ||
} | ||
|
||
public class FetchParticipantScheduleByIdExecutor( | ||
private val scheduleRepository: ScheduleRepository, | ||
private val participantRepository: ParticipantRepository, | ||
private val userRepository: UserRepository, | ||
) : FetchParticipantScheduleByIdUseCase { | ||
override suspend fun invoke(id: ScheduleId): FetchSingleContentResult<ParticipantSchedule> { | ||
val schedule = try { | ||
scheduleRepository.fetchSchedule(id = id) | ||
} catch (e: Throwable) { | ||
return FetchSingleContentResult.Failure(error = e.toNitoError()) | ||
} | ||
|
||
val participants = participantRepository.getParticipants(id) | ||
val profiles = userRepository.getProfiles(userIds = participants.toUserIdList()) | ||
val participantSchedule = transformToParticipantSchedule( | ||
schedule = schedule, | ||
participants = participants, | ||
userProfiles = profiles, | ||
) | ||
|
||
return FetchSingleContentResult.Success(participantSchedule) | ||
} | ||
|
||
private fun transformToParticipantSchedule( | ||
schedule: Schedule, | ||
participants: List<Participant>, | ||
userProfiles: List<UserProfile>, | ||
): ParticipantSchedule { | ||
val scheduleParticipants = participants.filter { it.scheduleId == schedule.id } | ||
val scheduleParticipantProfiles = userProfiles.filter { profile -> | ||
scheduleParticipants.any { it.userId == profile.id } | ||
} | ||
|
||
return ParticipantSchedule( | ||
id = schedule.id, | ||
scheduledAt = schedule.scheduledAt, | ||
metAt = schedule.metAt, | ||
venueId = schedule.venueId, | ||
meetId = schedule.meetId, | ||
description = schedule.description, | ||
participants = scheduleParticipantProfiles, | ||
) | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
core/domain/src/commonMain/kotlin/club/nito/core/domain/extension/ParticipantExtensions.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,13 @@ | ||
package club.nito.core.domain.extension | ||
|
||
import club.nito.core.model.participant.Participant | ||
|
||
/** | ||
* 重複を除いたユーザー ID のリストに変換する | ||
*/ | ||
internal fun List<Participant>.toDistinctUserIdList(): List<String> = distinctBy { it.userId }.toUserIdList() | ||
|
||
/** | ||
* ユーザー ID のリストに変換する | ||
*/ | ||
internal fun List<Participant>.toUserIdList(): List<String> = map { it.userId } |
3 changes: 2 additions & 1 deletion
3
core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.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
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
6 changes: 6 additions & 0 deletions
6
core/model/src/commonMain/kotlin/club/nito/core/model/schedule/ScheduleId.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,6 @@ | ||
package club.nito.core.model.schedule | ||
|
||
/** | ||
* スケジュールID | ||
*/ | ||
public typealias ScheduleId = String |
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
6 changes: 3 additions & 3 deletions
6
...ure/schedule/src/commonMain/kotlin/club/nito/feature/schedule/di/ScheduleFeatureModule.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
2 changes: 1 addition & 1 deletion
2
...ito/feature/schedule/ScheduleListEvent.kt → ...eature/schedule/list/ScheduleListEvent.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
2 changes: 1 addition & 1 deletion
2
...to/feature/schedule/ScheduleListIntent.kt → ...ature/schedule/list/ScheduleListIntent.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
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
2 changes: 1 addition & 1 deletion
2
...ure/schedule/ScheduleListScreenUiState.kt → ...chedule/list/ScheduleListScreenUiState.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package club.nito.feature.schedule | ||
package club.nito.feature.schedule.list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
パッケージ宣言が
|
||
|
||
import club.nito.core.common.NitoDateFormatter | ||
import club.nito.core.domain.model.ParticipantSchedule | ||
|
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.
ScheduleListViewModel
からScheduleListStateMachine
への変更が確認されました。しかし、app/ios/Modules/Sources/Schedule/ComposeScheduleListScreen.swift
においてScheduleListViewModel
の参照が残っているため、この部分の更新が必要です。新しいScheduleListStateMachine
の使用は他のファイルで確認されています。