TP-69510 | Vedant Aggarwal | Sorting Linked Accounts (#12528)
This commit is contained in:
@@ -123,7 +123,8 @@ constructor(
|
||||
val sortedLinkedAccounts =
|
||||
sortLinkedAccounts(
|
||||
linkedAccounts = linkedAccounts,
|
||||
accountTypePriorityStack = accountTypePriorityStack
|
||||
accountTypePriorityStack = accountTypePriorityStack,
|
||||
includeAllDetails = includeAllDetails
|
||||
)
|
||||
|
||||
if (!includeAllDetails) {
|
||||
@@ -167,22 +168,27 @@ constructor(
|
||||
|
||||
private fun sortLinkedAccounts(
|
||||
linkedAccounts: List<LinkedAccountEntity>,
|
||||
accountTypePriorityStack: Map<String, Int>
|
||||
accountTypePriorityStack: Map<String, Int>,
|
||||
includeAllDetails: Boolean
|
||||
): List<LinkedAccountEntity> {
|
||||
return linkedAccounts.sortedWith(
|
||||
compareBy(
|
||||
{ // Sort by priority stack
|
||||
accountTypePriorityStack[AccountType.getAccountType(it.accountType).name]
|
||||
?: Int.MAX_VALUE
|
||||
},
|
||||
{ // Place primary accounts first within the same account type
|
||||
!it.isAccountPrimary
|
||||
},
|
||||
{ // Sort by updatedTimestampDateTimeUTC from oldest to newest
|
||||
it.updatedAt
|
||||
}
|
||||
return if (includeAllDetails) {
|
||||
linkedAccounts.sortedWith(
|
||||
compareBy(
|
||||
{ // Sort by priority stack
|
||||
accountTypePriorityStack[AccountType.getAccountType(it.accountType).name]
|
||||
?: Int.MAX_VALUE
|
||||
},
|
||||
{ // Place primary accounts first within the same account type
|
||||
!it.isAccountPrimary
|
||||
},
|
||||
{ // Sort by updatedTimestampDateTimeUTC from oldest to newest
|
||||
it.updatedAt
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
linkedAccounts.sortedBy { !it.isAccountPrimary }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateBankUptimeStatusToLinkedAccounts(
|
||||
|
||||
Reference in New Issue
Block a user