Load all tracks in one query for statistics
This commit is contained in:
@@ -11,6 +11,10 @@ class GetTracksPerManga(
|
||||
private val trackRepository: TrackRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): Map<Long, List<Track>> {
|
||||
return trackRepository.getTracks().groupBy { it.mangaId }
|
||||
}
|
||||
|
||||
fun subscribe(): Flow<Map<Long, List<Track>>> {
|
||||
return trackRepository.getTracksAsFlow().map { tracks -> tracks.groupBy { it.mangaId } }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ interface TrackRepository {
|
||||
|
||||
suspend fun getTracksByMangaId(mangaId: Long): List<Track>
|
||||
|
||||
suspend fun getTracks(): List<Track>
|
||||
|
||||
fun getTracksAsFlow(): Flow<List<Track>>
|
||||
|
||||
fun getTracksByMangaIdAsFlow(mangaId: Long): Flow<List<Track>>
|
||||
|
||||
Reference in New Issue
Block a user