Skip to content

Commit

Permalink
Merge branch 'refactor-currency-services-focused-on-symbols' of https…
Browse files Browse the repository at this point in the history
…://github.com/opexdev/core into otc_to_dev_currency_services
  • Loading branch information
fatemeh-i committed Dec 16, 2024
2 parents 4c0ea65 + 7663c69 commit 4d053f7
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class InitializeService(

@PostConstruct
fun init() = runBlocking {
if (!environment.activeProfiles.contains("otc")) {
addCurrencies(preferences.currencies)
addUserLimits(preferences.userLimits)
}
// if (!environment.activeProfiles.contains("otc")) {
// addCurrencies(preferences.currencies)
// addUserLimits(preferences.userLimits)
// }
addSystemAndAdminWallet(preferences)
}

Expand Down Expand Up @@ -91,21 +91,23 @@ class InitializeService(
)
).awaitSingleOrNull()

val items = p.currencies.flatMap { currency ->
listOf(
WalletModel(1, WalletType.MAIN, currency.symbol, currency.mainBalance),
WalletModel(1, WalletType.EXCHANGE, currency.symbol, BigDecimal.ZERO),
WalletModel(adminWallet?.id!!, WalletType.MAIN, currency.symbol, currency.mainBalance),
WalletModel(adminWallet.id!!, WalletType.EXCHANGE, currency.symbol, BigDecimal.ZERO)
)
}
runCatching { walletRepository.saveAll(items).collectList().awaitSingleOrNull() }
// val items = p.currencies.flatMap { currency ->
// listOf(
// WalletModel(1, WalletType.MAIN, currency.symbol, currency.mainBalance),
// WalletModel(1, WalletType.EXCHANGE, currency.symbol, BigDecimal.ZERO),
// WalletModel(adminWallet?.id!!, WalletType.MAIN, currency.symbol, currency.mainBalance),
// WalletModel(adminWallet.id!!, WalletType.EXCHANGE, currency.symbol, BigDecimal.ZERO)
// )
// }
// runCatching { walletRepository.saveAll(items).collectList().awaitSingleOrNull() }
}


private suspend fun addCurrencies(data: List<Currency>) = coroutineScope {
data.forEach {
currencyRepository.insert(it.name, it.symbol, it.name, it.precision).awaitSingleOrNull()
}
}
// private suspend fun addCurrencies(data: List<Currency>) = coroutineScope {
// data.forEach {
// runCatching {
// currencyRepository.insert(it.name, it.symbol, it.name, it.precision).awaitSingleOrNull()
// }
// }
// }
}

0 comments on commit 4d053f7

Please sign in to comment.