Skip to content

Commit

Permalink
Improve AssetsRequest join request
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Aug 28, 2024
1 parent 07f50fd commit 562ba8d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Packages/Store/Sources/Requests/AssetsRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,12 @@ public struct AssetsRequest: Queryable {
.including(optional: AssetRecord.balance)
.including(optional: AssetRecord.details)
.including(optional: AssetRecord.account)
.filter(literal:
SQL(stringLiteral: String(format:"%@.walletId = '%@'", AssetBalanceRecord.databaseTableName, walletID))
)
.filter(literal:
SQL(stringLiteral: String(format:"%@.walletId = '%@'", AccountRecord.databaseTableName, walletID))
.joining(optional: AssetRecord.balance
.filter(Columns.Balance.walletId == walletID)
.order(Columns.Balance.fiatValue.desc)
)
.order(literal:
SQL(stringLiteral: String(format: "%@.fiatValue DESC", AssetBalanceRecord.databaseTableName))
)

.joining(optional: AssetRecord.account.filter(Columns.Account.walletId == walletID))

if !searchBy.isEmpty {
request = Self.applyFilter(request: request, .search(searchBy))
}
Expand Down

0 comments on commit 562ba8d

Please sign in to comment.