Skip to content

Commit

Permalink
Minor wormbase.ids.batch code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mluypaert committed Sep 4, 2020
1 parent c2c8ea4 commit a1a87a8
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions ids/src/wormbase/ids/batch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[clojure.core :as cc]
[clojure.set :as set]
[datomic.api :as d]
[wormbase.ids.core :refer [attr-schema-unique? identifier-format]]))
[wormbase.ids.core :refer [identifier-format]]))

(defn- assoc-prov
"Attach an identifier to `prov` making this a mapping suitable for tracking provenance for a batch.
Expand Down Expand Up @@ -65,32 +65,32 @@
(let [sp (assoc-prov prov)
batch (partition-all batch-size coll)
db (d/db conn)
init-tx-res (map->BatchResult {:tx-result {:db-after db} :errors nil})]
(let [result (reduce
(partial processor-fn
sp
(fn [result xs]
(when (get-in result [:tx-result :db-after])
(attempt-batch result xs))))
init-tx-res
batch)]
(let [errors (-> result :errors seq)]
(when (seq errors)
(throw (ex-info "Errors during batch processing"
{:errors errors
:type ::db-errors}))))
(let [b-result (reduce (partial processor-fn
sp
(fn [_ xs]
(assoc result
:tx-result
@(d/transact-async conn xs))))
(map->BatchResult {:tx-result {:db-after db}})
batch)]
(when (get-in b-result [:tx-result :db-after])
(-> sp
(select-keys [:batch/id])
(set/rename-keys {:batch/id :id})))))))
init-tx-res (map->BatchResult {:tx-result {:db-after db} :errors nil})
result (reduce
(partial processor-fn
sp
(fn [result xs]
(when (get-in result [:tx-result :db-after])
(attempt-batch result xs))))
init-tx-res
batch)]
(let [errors (-> result :errors seq)]
(when (seq errors)
(throw (ex-info "Errors during batch processing"
{:errors errors
:type ::db-errors}))))
(let [b-result (reduce (partial processor-fn
sp
(fn [_ xs]
(assoc result
:tx-result
@(d/transact-async conn xs))))
(map->BatchResult {:tx-result {:db-after db}})
batch)]
(when (get-in b-result [:tx-result :db-after])
(-> sp
(select-keys [:batch/id])
(set/rename-keys {:batch/id :id}))))))

(defn merge-genes
"Merge genes.
Expand Down

0 comments on commit a1a87a8

Please sign in to comment.