Retrieving account transactions in parallel not serially
This commit is contained in:
parent
54ca55e2f9
commit
e0e150e53a
|
@ -207,19 +207,22 @@ class BankingService(
|
||||||
|
|
||||||
|
|
||||||
suspend fun updateAccountTransactions() {
|
suspend fun updateAccountTransactions() {
|
||||||
|
withContext(Dispatchers.IOorDefault) {
|
||||||
val selectedAccount = uiState.transactionsFilter.value.selectedAccount
|
val selectedAccount = uiState.transactionsFilter.value.selectedAccount
|
||||||
if (selectedAccount != null) {
|
if (selectedAccount != null) {
|
||||||
updateAccountTransactions(selectedAccount.bank, selectedAccount.bankAccount)
|
updateAccountTransactions(selectedAccount.bank, selectedAccount.bankAccount)
|
||||||
} else {
|
} else {
|
||||||
getCurrentUiBanksList().forEach { bank ->
|
getCurrentUiBanksList().forEach { bank ->
|
||||||
|
launch {
|
||||||
// TODO: when implementing automatic account transactions update, filter out accounts with includeInAutomaticAccountsUpdate == false
|
// TODO: when implementing automatic account transactions update, filter out accounts with includeInAutomaticAccountsUpdate == false
|
||||||
updateAccountTransactions(bank)
|
updateAccountTransactions(bank)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun updateAccountTransactions(bank: BankAccessEntity, bankAccount: BankAccountEntity? = null) {
|
private suspend fun updateAccountTransactions(bank: BankAccessEntity, bankAccount: BankAccountEntity? = null) {
|
||||||
withContext(Dispatchers.IOorDefault) {
|
|
||||||
try {
|
try {
|
||||||
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
||||||
if (response.type == ResponseType.Success && response.data != null) {
|
if (response.type == ResponseType.Success && response.data != null) {
|
||||||
|
@ -231,7 +234,6 @@ class BankingService(
|
||||||
log.error(e) { "Could not update account transactions for $bank" }
|
log.error(e) { "Could not update account transactions for $bank" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun handleSuccessfulUpdateAccountTransactionsResponse(bank: BankAccessEntity, responses: List<GetTransactionsResponse>) {
|
private suspend fun handleSuccessfulUpdateAccountTransactionsResponse(bank: BankAccessEntity, responses: List<GetTransactionsResponse>) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue