From 0ff147a7a0f5015e68adf89b73ccbd0db163b68e Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 3 Mar 2023 10:03:16 -0800 Subject: [PATCH] Should give a bit more clarity if refunds don't load --- src/clj/auto_ap/square/core3.clj | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/clj/auto_ap/square/core3.clj b/src/clj/auto_ap/square/core3.clj index 8cf54bc6..ed0b9a73 100644 --- a/src/clj/auto_ap/square/core3.clj +++ b/src/clj/auto_ap/square/core3.clj @@ -589,19 +589,27 @@ ([client] (apply de/zip (for [square-location (:client/square-locations client) - :when (:square-location/client-location square-location)] + :when (:square-location/client-location square-location)] (upsert-refunds client square-location)))) ([client location] - (de/chain (refunds client location) - (fn [refunds] - (mu/with-context {:source "Loading Square Settlements" - :client (:client/code client) - :location (:square-location/client-location client)} - (doseq [x (partition-all 100 refunds)] - (log/info ::loading-refunds - :count (count x)) - @(d/transact conn x)) - (log/info ::done-loading-refunds)))))) + (with-context-as {:source "Square refunds loading" + :client (:client/code client)} lc + + (de/chain (refunds client location) + (fn [refunds] + (mu/with-context lc + (try + (doseq [x (partition-all 100 refunds)] + (log/info ::loading-refunds + :count (count x) + :sample (first x)) + @(d/transact conn x)) + + (catch Throwable e + (log/error ::upsert-refunds-failed + :exception e))) + + (log/info ::done-loading-refunds))))))) (def square-read [:db/id :client/code