From f8b69a1c87cf4e54db04414f63eab58af46961da Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 2 May 2023 14:40:26 -0500 Subject: [PATCH] Improve load of payments into DB --- src/ZGoBackend.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 7cf505f..6b52d25 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -523,9 +523,16 @@ upsertPayment pipe dbName p = do (memo p) let payment = val payTx case payment of - Doc d -> - access pipe master dbName $ - upsert (select ["txid" =: txid p] "payments") d + Doc d -> do + results <- + access + pipe + master + dbName + (rest =<< find (select ["txid" =: txid p] "payments")) + when (null results) $ + access pipe master dbName $ + upsert (select ["txid" =: txid p] "payments") d _ -> return () authSettings :: AuthSettings