Migrates back to datomic on-prem
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[datomic.client.api :as dc]
|
||||
[datomic.api :as dc]
|
||||
[manifold.deferred :as de]
|
||||
[manifold.executor :as ex]
|
||||
[manifold.stream :as s]
|
||||
@@ -562,7 +562,7 @@
|
||||
(doseq [x (partition-all 100 results)]
|
||||
(log/info ::loading-orders
|
||||
:count (count x))
|
||||
(dc/transact conn {:tx-data x}))))))))
|
||||
@(dc/transact conn x))))))))
|
||||
|
||||
|
||||
(defn upsert-settlements
|
||||
@@ -582,7 +582,7 @@
|
||||
(doseq [x (partition-all 20 settlements)]
|
||||
(log/info ::loading-deposits
|
||||
:count (count x))
|
||||
(dc/transact conn {:tx-data x}))
|
||||
@(dc/transact conn x))
|
||||
(log/info ::done-loading-deposits)))))))
|
||||
|
||||
(defn upsert-refunds
|
||||
@@ -603,7 +603,7 @@
|
||||
(log/info ::loading-refunds
|
||||
:count (count x)
|
||||
:sample (first x))
|
||||
(dc/transact conn {:tx-data x}))
|
||||
@(dc/transact conn x))
|
||||
|
||||
(catch Throwable e
|
||||
(log/error ::upsert-refunds-failed
|
||||
@@ -653,30 +653,30 @@
|
||||
(:client/square-locations client)))]
|
||||
(de/chain (client-locations client)
|
||||
(fn [client-locations]
|
||||
(dc/transact conn
|
||||
{:tx-data (for [square-location client-locations]
|
||||
{:db/id (or (square-id->id (:id square-location)) (str (java.util.UUID/randomUUID)))
|
||||
:client/_square-locations (:db/id client)
|
||||
:square-location/name (:name square-location)
|
||||
:square-location/square-id (:id square-location)})}))))))
|
||||
@(dc/transact conn
|
||||
(for [square-location client-locations]
|
||||
{:db/id (or (square-id->id (:id square-location)) (str (java.util.UUID/randomUUID)))
|
||||
:client/_square-locations (:db/id client)
|
||||
:square-location/name (:name square-location)
|
||||
:square-location/square-id (:id square-location)})))))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn reset []
|
||||
(->>
|
||||
(dc/q {:query {:find ['?e]
|
||||
:in ['$]
|
||||
:where ['(or [?e :sales-order/date]
|
||||
[?e :expected-deposit/date])]}
|
||||
:args [(dc/db conn)]})
|
||||
(dc/q {:find ['?e]
|
||||
:in ['$]
|
||||
:where ['(or [?e :sales-order/date]
|
||||
[?e :expected-deposit/date])]}
|
||||
(dc/db conn))
|
||||
(map first)
|
||||
(map (fn [x] [:db/retractEntity x]))))
|
||||
|
||||
(defn mark-integration-status [client integration-status]
|
||||
(dc/transact conn
|
||||
{:tx-data [{:db/id (:db/id client)
|
||||
:client/square-integration-status (assoc integration-status
|
||||
:db/id (or (-> client :client/square-integration-status :db/id)
|
||||
(str (java.util.UUID/randomUUID))))}]}))
|
||||
@(dc/transact conn
|
||||
[{:db/id (:db/id client)
|
||||
:client/square-integration-status (assoc integration-status
|
||||
:db/id (or (-> client :client/square-integration-status :db/id)
|
||||
(str (java.util.UUID/randomUUID))))}]))
|
||||
|
||||
(defn upsert-all [ & clients]
|
||||
(capture-context->lc
|
||||
|
||||
Reference in New Issue
Block a user