Refactor transaction fetching in LamassuTransactionProcessor: update SQL query to filter for confirmed and authorized transactions, ensuring only valid dispenses are retrieved. Adjust transaction time field to use confirmed_at for improved accuracy.
This commit is contained in:
parent
63638c089f
commit
c5755d48d1
1 changed files with 8 additions and 4 deletions
|
|
@ -444,12 +444,14 @@ class LamassuTransactionProcessor:
|
||||||
time_threshold_str = time_threshold.strftime('%Y-%m-%d %H:%M:%S UTC')
|
time_threshold_str = time_threshold.strftime('%Y-%m-%d %H:%M:%S UTC')
|
||||||
|
|
||||||
# First, get all transactions since the threshold from Lamassu database
|
# First, get all transactions since the threshold from Lamassu database
|
||||||
|
# Filter out unconfirmed dispenses
|
||||||
|
# TODO: review
|
||||||
lamassu_query = f"""
|
lamassu_query = f"""
|
||||||
SELECT
|
SELECT
|
||||||
co.id as transaction_id,
|
co.id as transaction_id,
|
||||||
co.fiat as fiat_amount,
|
co.fiat as fiat_amount,
|
||||||
co.crypto_atoms as crypto_amount,
|
co.crypto_atoms as crypto_amount,
|
||||||
co.created as transaction_time,
|
co.confirmed_at as transaction_time,
|
||||||
co.device_id,
|
co.device_id,
|
||||||
co.status,
|
co.status,
|
||||||
co.commission_percentage,
|
co.commission_percentage,
|
||||||
|
|
@ -457,9 +459,11 @@ class LamassuTransactionProcessor:
|
||||||
co.crypto_code,
|
co.crypto_code,
|
||||||
co.fiat_code
|
co.fiat_code
|
||||||
FROM cash_out_txs co
|
FROM cash_out_txs co
|
||||||
WHERE co.created > '{time_threshold_str}'
|
WHERE co.confirmed_at > '{time_threshold_str}'
|
||||||
AND co.status = 'confirmed'
|
AND co.status IN ('confirmed', 'authorized')
|
||||||
ORDER BY co.created DESC
|
AND co.dispense = 't'
|
||||||
|
AND co.dispense_confirmed = 't'
|
||||||
|
ORDER BY co.confirmed_at DESC
|
||||||
"""
|
"""
|
||||||
|
|
||||||
all_transactions = await self.execute_ssh_query(db_config, lamassu_query)
|
all_transactions = await self.execute_ssh_query(db_config, lamassu_query)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue