Add fiatAmount and fiatSymbol members to the TransferDetail object and modify the query to fetch TransferDetails from the database to obtain those two objects from the EquivalentValues table if they have been already obtained
This commit is contained in:
parent
577e3ae01f
commit
0b287ca714
2 changed files with 5 additions and 5 deletions
|
@ -10,9 +10,9 @@ data class TransferDetail(
|
||||||
val assetAmount: Long,
|
val assetAmount: Long,
|
||||||
val assetPrecision: Int,
|
val assetPrecision: Int,
|
||||||
val assetSymbol: String,
|
val assetSymbol: String,
|
||||||
val assetIssuer: String
|
val assetIssuer: String,
|
||||||
// val fiatAmount: Long,
|
val fiatAmount: Long?,
|
||||||
// val fiatCurrency: String
|
val fiatSymbol: String?
|
||||||
) {
|
) {
|
||||||
fun getUIAssetSymbol(): String {
|
fun getUIAssetSymbol(): String {
|
||||||
if (assetIssuer == "1.2.0")
|
if (assetIssuer == "1.2.0")
|
||||||
|
|
|
@ -7,9 +7,9 @@ import androidx.room.Query
|
||||||
@Dao
|
@Dao
|
||||||
interface TransferDetailDao {
|
interface TransferDetailDao {
|
||||||
|
|
||||||
@Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `assetAmount`, assets.precision AS `assetPrecision`, assets.symbol AS `assetSymbol`, assets.issuer as `assetIssuer` FROM transfers INNER JOIN assets WHERE transfers.id=:transferId AND transfers.transfer_asset_id = assets.id")
|
@Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `assetAmount`, assets.precision AS `assetPrecision`, assets.symbol AS `assetSymbol`, assets.issuer as `assetIssuer`, (SELECT value FROM equivalent_values WHERE equivalent_values.transfer_id=transfers.id) AS `fiatAmount`, (SELECT symbol FROM equivalent_values WHERE equivalent_values.transfer_id=transfers.id) AS `fiatSymbol` FROM transfers INNER JOIN assets WHERE transfers.id=:transferId AND transfers.transfer_asset_id = assets.id")
|
||||||
fun get(userId: String, transferId: String): LiveData<TransferDetail>
|
fun get(userId: String, transferId: String): LiveData<TransferDetail>
|
||||||
|
|
||||||
@Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `assetAmount`, assets.precision AS `assetPrecision`, assets.symbol AS `assetSymbol`, assets.issuer as `assetIssuer` FROM transfers INNER JOIN assets WHERE transfers.transfer_asset_id = assets.id")
|
@Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `assetAmount`, assets.precision AS `assetPrecision`, assets.symbol AS `assetSymbol`, assets.issuer as `assetIssuer`, (SELECT value FROM equivalent_values WHERE equivalent_values.transfer_id=transfers.id) AS `fiatAmount`, (SELECT symbol FROM equivalent_values WHERE equivalent_values.transfer_id=transfers.id) AS `fiatSymbol` FROM transfers INNER JOIN assets WHERE transfers.transfer_asset_id = assets.id")
|
||||||
fun getAll(userId: String): LiveData<List<TransferDetail>>
|
fun getAll(userId: String): LiveData<List<TransferDetail>>
|
||||||
}
|
}
|
Loading…
Reference in a new issue