Fixed equivalent value errors in the transactions by making sure the equivalent value is only fetched for transfers that already have the timestamp value updated.
This commit is contained in:
parent
d0109c42d5
commit
776e5f42b7
2 changed files with 4 additions and 4 deletions
|
@ -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<Transfer>
|
||||
|
||||
@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<Transfer>
|
||||
|
||||
@Query("DELETE FROM transfers")
|
||||
|
|
|
@ -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<Transfer>) {
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue