minor tweaks for square integration.

This commit is contained in:
2022-07-11 15:25:54 -07:00
parent c37af2a188
commit bb6592bd71

View File

@@ -268,7 +268,7 @@
output-chan output-chan
(map (fn [p] (map (fn [p]
(lc/with-context {:source "Square settlements loading "} (lc/with-context {:source "Square settlements loading "}
(log/info "looking up payment " p " for settlement " (:id settlement)) (log/trace "looking up payment " p " for settlement " (:id settlement))
(or (or
(-> (get-payment client p) (-> (get-payment client p)
:created_at :created_at
@@ -415,7 +415,8 @@
:when (:square-location/client-location square-location)] :when (:square-location/client-location square-location)]
(upsert-settlements client square-location))) (upsert-settlements client square-location)))
([client location] ([client location]
(lc/with-context {:source "Square settlements loading"} (lc/with-context {:source "Square settlements loading"
:client (:client/code client)}
(doseq [x (partition-all 20 (daily-settlements client location))] (doseq [x (partition-all 20 (daily-settlements client location))]
(log/info "Loading expected deposit" (count x)) (log/info "Loading expected deposit" (count x))
@(d/transact conn x)) @(d/transact conn x))
@@ -519,9 +520,11 @@
:integration-status/message (-> data :body str)})) :integration-status/message (-> data :body str)}))
(catch Object e (catch Object e
(log/warn e) (log/warn &throw-context)
(mark-integration-status client {:integration-status/state :integration-state/failed (mark-integration-status client {:integration-status/state :integration-state/failed
:integration-status/message (.getMessage (:wrapper &throw-context))})))))) :integration-status/message (or (some-> (:wrapper &throw-context) (.getMessage ))
(some-> (:object &throw-context) str)
"Unknown error")}))))))
(mount/defstate square-loader (mount/defstate square-loader
:start (scheduler/every (* 4 59 60 1000) (heartbeat upsert-all "square-loading")) :start (scheduler/every (* 4 59 60 1000) (heartbeat upsert-all "square-loading"))