Skip to content

Commit

Permalink
feat: Disable Strahov and Kocourkov menzas
Browse files Browse the repository at this point in the history
  • Loading branch information
Lastaapps committed Jul 3, 2024
1 parent db21b8f commit d53cd43
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private fun SubsystemEntity.toDomain() =
Menza(
Subsystem(id.toInt()),
name,
true,
opened,
supportsDaily,
supportsWeekly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ internal object MenzaStrahovRepoImpl : MenzaRepo {
Menza(
type = Strahov,
name = getName(params),
isActive = false,
isOpened = true,
supportsDaily = true,
supportsWeekly = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ internal object MenzaFSRepoImpl : MenzaRepo {
Menza(
type = FS,
name = "Bufet FS",
isActive = true,
isOpened = true,
supportsDaily = true,
supportsWeekly = true,
Expand Down Expand Up @@ -80,6 +81,7 @@ internal object MenzaFELRepoImpl : MenzaRepo {
Menza(
type = FEL,
name = "Bufet FEL",
isActive = true,
isOpened = true,
supportsDaily = true,
supportsWeekly = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import kotlinx.collections.immutable.ImmutableList
data class Menza(
val type: MenzaType,
val name: String,
val isActive: Boolean,
val isOpened: Boolean,
val supportsDaily: Boolean,
val supportsWeekly: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import cz.lastaapps.api.core.domain.repo.WeekRepoParams
import cz.lastaapps.api.core.domain.sync.SyncOutcome
import cz.lastaapps.api.core.domain.sync.SyncResult
import cz.lastaapps.api.core.domain.sync.SyncResult.Unavailable
import cz.lastaapps.core.data.AppInfoProvider
import cz.lastaapps.core.util.extensions.localLogger
import kotlin.random.Random
import kotlin.random.nextInt
Expand All @@ -53,7 +54,9 @@ import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
import org.koin.core.component.KoinComponent

internal class KocourkovRepoImpl : MenzaRepo {
internal class KocourkovRepoImpl(
private val appInfoProvider: AppInfoProvider,
) : MenzaRepo {
override fun isReady(params: MenzaRepoParams): Flow<Boolean> = flow {
emit(true)
}
Expand All @@ -64,6 +67,7 @@ internal class KocourkovRepoImpl : MenzaRepo {
Menza(
MenzaType.Testing.Kocourkov,
name = "Kocourkov",
isActive = appInfoProvider.isDebug(),
isOpened = true,
supportsDaily = true,
supportsWeekly = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ val apiModule = module {
factoryOf(::GetImportantRequestParams)

registerMenzaType<MenzaType.Testing.Kocourkov>(
menzaRepo = { KocourkovRepoImpl() },
menzaRepo = { KocourkovRepoImpl(get()) },
dishRepo = { TodayKocourkovDishRepoImpl },
infoRepo = { InfoKocourkovRepoImpl },
weekRepo = { WeekKocourkovRepoImpl },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@

package cz.lastaapps.api.main.domain.usecase

import cz.lastaapps.api.core.domain.sync.getData
import cz.lastaapps.api.core.domain.sync.sync
import cz.lastaapps.api.core.domain.model.Menza
import cz.lastaapps.api.core.domain.repo.MenzaRepo
import cz.lastaapps.api.core.domain.sync.getData
import cz.lastaapps.core.domain.UCContext
import cz.lastaapps.core.domain.UseCase
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.map

class GetMenzaListUC(
context: UCContext,
private val menzaRepo: MenzaRepo,
private val getRequestParamsUC: GetRequestParamsUC,
) : UseCase(context) {
operator fun invoke() = menzaRepo.getData(getRequestParamsUC())
.map { it.filter(Menza::isActive) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ private fun MenzaItemPreview() {
menza = Menza(
Strahov,
"Menza Strahov",
isActive = true,
isOpened = true,
supportsDaily = true,
supportsWeekly = true,
Expand All @@ -255,6 +256,7 @@ private fun MenzaItemPreview() {
menza = Menza(
Strahov,
"Restaurace Strahov",
isActive = true,
isOpened = true,
supportsDaily = true,
supportsWeekly = true,
Expand Down

0 comments on commit d53cd43

Please sign in to comment.