Migrates back to datomic on-prem
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(ns auto-ap.ezcater.core
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn random-tempid]]
|
||||
[datomic.client.api :as dc]
|
||||
[datomic.api :as dc]
|
||||
[clj-http.client :as client]
|
||||
[venia.core :as v]
|
||||
[clojure.string :as str]
|
||||
@@ -44,21 +44,21 @@
|
||||
(dc/db conn))))
|
||||
|
||||
(defn mark-integration-status [integration integration-status]
|
||||
(dc/transact conn
|
||||
{:tx-data [{:db/id (:db/id integration)
|
||||
:ezcater-integration/integration-status (assoc integration-status
|
||||
:db/id (or (-> integration :ezcater-integration/integration-status :db/id)
|
||||
(random-tempid)))}]}))
|
||||
@(dc/transact conn
|
||||
[{:db/id (:db/id integration)
|
||||
:ezcater-integration/integration-status (assoc integration-status
|
||||
:db/id (or (-> integration :ezcater-integration/integration-status :db/id)
|
||||
(random-tempid)))}]))
|
||||
|
||||
(defn upsert-caterers
|
||||
([integration]
|
||||
(dc/transact
|
||||
@(dc/transact
|
||||
conn
|
||||
{:tx-data (for [caterer (get-caterers integration)]
|
||||
{:db/id (:db/id integration)
|
||||
:ezcater-integration/caterers [{:ezcater-caterer/name (str (:name caterer) " (" (:street (:address caterer)) ")")
|
||||
:ezcater-caterer/search-terms (str (:name caterer) " " (:street (:address caterer)))
|
||||
:ezcater-caterer/uuid (:uuid caterer)}]})})))
|
||||
(for [caterer (get-caterers integration)]
|
||||
{:db/id (:db/id integration)
|
||||
:ezcater-integration/caterers [{:ezcater-caterer/name (str (:name caterer) " (" (:street (:address caterer)) ")")
|
||||
:ezcater-caterer/search-terms (str (:name caterer) " " (:street (:address caterer)))
|
||||
:ezcater-caterer/uuid (:uuid caterer)}]}))))
|
||||
|
||||
(defn upsert-used-subscriptions
|
||||
([integration]
|
||||
@@ -270,12 +270,12 @@
|
||||
(alog/info
|
||||
::try-import-order
|
||||
:json json)
|
||||
(dc/transact conn {:tx-data (filter identity
|
||||
[(some-> json
|
||||
(lookup-order)
|
||||
(order->sales-order)
|
||||
(update :sales-order/date coerce/to-date)
|
||||
(update-in [:sales-order/charges 0 :charge/date] coerce/to-date))])}))
|
||||
@(dc/transact conn (filter identity
|
||||
[(some-> json
|
||||
(lookup-order)
|
||||
(order->sales-order)
|
||||
(update :sales-order/date coerce/to-date)
|
||||
(update-in [:sales-order/charges 0 :charge/date] coerce/to-date))])))
|
||||
|
||||
(defn upsert-recent []
|
||||
(upsert-ezcater)
|
||||
@@ -346,6 +346,6 @@
|
||||
updated-order))]
|
||||
(alog/info :found-orders-to-update
|
||||
:orders orders-to-update)
|
||||
(dc/transact conn {:tx-data orders-to-update})))
|
||||
@(dc/transact conn orders-to-update)))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user