no need for transact-with-ledger.
This commit is contained in:
@@ -459,45 +459,6 @@
|
||||
:priority :low}
|
||||
nil))
|
||||
|
||||
(defn transact-with-ledger [transaction id]
|
||||
(let [db (dc/db conn)
|
||||
tx (audit-transact transaction id)
|
||||
affected-entities (->> (:tx-data tx)
|
||||
(map (fn [x]
|
||||
{:e (:e x)
|
||||
:a (:a x)
|
||||
:v (:v x)
|
||||
:added (:added x)}))
|
||||
(group-by :e)
|
||||
(mapcat #(datums->impacted-entity db %))
|
||||
(set))
|
||||
ledger-txs (->> affected-entities
|
||||
(map #(entity-change->ledger (:db-after tx) %))
|
||||
(filter seq)
|
||||
(map (fn [l]
|
||||
`(upsert-ledger ~l))))]
|
||||
(when (seq ledger-txs)
|
||||
(audit-transact ledger-txs id))
|
||||
tx))
|
||||
|
||||
(defn transact-batch-with-ledger [txes id]
|
||||
(let [batch-id (.toString (java.util.UUID/randomUUID))]
|
||||
(reduce
|
||||
(fn [full-tx batch]
|
||||
(let [batch (conj (vec batch) {:db/id "datomic.tx"
|
||||
:audit/batch batch-id})
|
||||
_ (log/info "transacting batch " batch-id " " (count batch))
|
||||
tx-result (transact-with-ledger batch id)]
|
||||
|
||||
(cond-> full-tx
|
||||
(:tx-data full-tx) (update :tx-data #(into % (:tx-data tx-result)))
|
||||
(not (:tx-data full-tx)) (assoc :tx-data (vec (:tx-data tx-result)))
|
||||
(not (:db-before full-tx)) (assoc :db-before (:db-before tx-result))
|
||||
true (assoc :db-after (:db-after tx-result))
|
||||
true (update :tempids merge (:tempids tx-result)))))
|
||||
|
||||
{}
|
||||
(partition-all 50 txes))))
|
||||
|
||||
(defn build-account-lookup [client-id]
|
||||
(let [accounts (by :db/id (map first (dc/q {:query {:find ['(pull ?e [:db/id :account/name
|
||||
|
||||
Reference in New Issue
Block a user