diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/TransferDao.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/TransferDao.kt index 306e849..5070f6b 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/TransferDao.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/TransferDao.kt @@ -33,7 +33,7 @@ interface TransferDao { @Query("SELECT * FROM transfers WHERE timestamp != 0 AND bts_value = -1 AND transfer_asset_id != '1.3.0' LIMIT 1") fun getTransfersWithMissingBtsValue(): LiveData - @Query("SELECT * FROM transfers WHERE id NOT IN (SELECT transfer_id FROM equivalent_values WHERE symbol = :symbol) AND bts_value >= 0 LIMIT 1") + @Query("SELECT * FROM transfers WHERE id NOT IN (SELECT transfer_id FROM equivalent_values WHERE symbol = :symbol) AND bts_value >= 0 AND timestamp > 0 LIMIT 1") fun getTransfersWithMissingValueIn(symbol: String): Observable @Query("DELETE FROM transfers") diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/repositories/TransferRepository.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/repositories/TransferRepository.kt index 55b029d..d82c31f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/repositories/TransferRepository.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/repositories/TransferRepository.kt @@ -27,7 +27,7 @@ class TransferRepository internal constructor(context: Context) { init { val db = BitsyDatabase.getDatabase(context) mTransferDao = db!!.transferDao() - mEquivalentValuesDao = db!!.equivalentValueDao() + mEquivalentValuesDao = db.equivalentValueDao() } fun insertAll(transfers: List) { @@ -92,13 +92,13 @@ class TransferRepository internal constructor(context: Context) { * Creates an equivalent value for a given transaction. * * Function used to perform a request to the Coingecko's price API trying to obtain the - * equivalent value of a specific [Transaction]. + * equivalent value of a specific [Transfer]. * * @param transfer The transfer whose equivalent value we want to obtain * @param symbol The symbol of the fiat that the equivalent value should be calculated in * @return An instance of the [EquivalentValue] class, ready to be inserted into the database. */ - fun obtainFiatValue(transfer: Transfer, symbol: String): EquivalentValue { + private fun obtainFiatValue(transfer: Transfer, symbol: String): EquivalentValue { val sg = ServiceGenerator(Constants.COINGECKO_URL) val dateFormat = SimpleDateFormat("dd-MM-yyyy", Locale.ROOT) val date = Date(transfer.timestamp * 1000)