Coverage Summary for Class: GetBudgetsUseCase (com.georgeci.moneysurfer.domain.usecase)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| GetBudgetsUseCase |
100%
(3/3)
|
66.7%
(4/6)
|
100%
(5/5)
|
100%
(14/14)
|
| GetBudgetsUseCase$invoke$$inlined$flatMapLatest$1 |
0%
(0/1)
|
|
| Total |
75%
(3/4)
|
66.7%
(4/6)
|
100%
(5/5)
|
100%
(14/14)
|
package com.georgeci.moneysurfer.domain.usecase
import com.georgeci.moneysurfer.domain.auth.SessionPointers
import com.georgeci.moneysurfer.domain.model.Budget
import com.georgeci.moneysurfer.domain.repositories.BudgetRepository
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import org.koin.core.annotation.Single
@Single
@OptIn(ExperimentalCoroutinesApi::class)
class GetBudgetsUseCase(
private val budgetRepository: BudgetRepository,
private val session: SessionPointers,
) {
/** Every budget of the active workspace, archived ones included — the caller splits them. */
operator fun invoke(): Flow<List<Budget>> =
session.currentWorkspaceId.flatMapLatest { workspaceId ->
workspaceId?.let(budgetRepository::getByWorkspaceId) ?: flowOf(emptyList())
}
}