Does not use timeouts for background processing
This commit is contained in:
@@ -187,24 +187,23 @@
|
|||||||
clients (dc/q '[:find (pull ?c [:db/id :client/code {:client/bank-accounts [:db/id :bank-account/code]}])
|
clients (dc/q '[:find (pull ?c [:db/id :client/code {:client/bank-accounts [:db/id :bank-account/code]}])
|
||||||
:where [?c :client/code]]
|
:where [?c :client/code]]
|
||||||
db )]
|
db )]
|
||||||
@(dc/transact conn
|
(doseq [[{client :db/id code :client/code bank-accounts :client/bank-accounts}] clients
|
||||||
(for [[{client :db/id code :client/code bank-accounts :client/bank-accounts}] clients
|
{bank-account :db/id bac :bank-account/code} bank-accounts]
|
||||||
{bank-account :db/id bac :bank-account/code} bank-accounts]
|
@(dc/transact conn [{:db/id bank-account
|
||||||
{:db/id bank-account
|
:bank-account/current-balance
|
||||||
:bank-account/current-balance
|
(or
|
||||||
(or
|
(->> (dc/index-pull db
|
||||||
(->> (dc/index-pull db
|
{:index :avet
|
||||||
{:index :avet
|
:selector [:db/id :journal-entry-line/location :journal-entry-line/account :journal-entry-line/running-balance :journal-entry-line/client+account+location+date {:journal-entry/_line-items [:journal-entry/date :journal-entry/client]}]
|
||||||
:selector [:db/id :journal-entry-line/location :journal-entry-line/account :journal-entry-line/running-balance :journal-entry-line/client+account+location+date {:journal-entry/_line-items [:journal-entry/date :journal-entry/client]}]
|
:start [:journal-entry-line/client+account+location+date [client bank-account "A" #inst "2030-01-01"]]
|
||||||
:start [:journal-entry-line/client+account+location+date [client bank-account "A" #inst "2030-01-01"]]
|
:reverse true
|
||||||
:reverse true
|
})
|
||||||
})
|
(filter (fn [{[c b] :journal-entry-line/client+account+location+date}]
|
||||||
(filter (fn [{[c b] :journal-entry-line/client+account+location+date}]
|
(and (= c client)
|
||||||
(and (= c client)
|
(= b bank-account))))
|
||||||
(= b bank-account))))
|
(map :journal-entry-line/running-balance)
|
||||||
(map :journal-entry-line/running-balance)
|
(first))
|
||||||
(first))
|
0.0)}])))))
|
||||||
0.0)})))))
|
|
||||||
|
|
||||||
(defn get-client [context _ _]
|
(defn get-client [context _ _]
|
||||||
(->graphql
|
(->graphql
|
||||||
|
|||||||
@@ -407,7 +407,7 @@
|
|||||||
(daily-results client location start end))]
|
(daily-results client location start end))]
|
||||||
(doseq [x (partition-all 20 to-create)]
|
(doseq [x (partition-all 20 to-create)]
|
||||||
(log/info "Loading " (count x))
|
(log/info "Loading " (count x))
|
||||||
@(dc/transact conn x))))))
|
@(dc/transact-async conn x))))))
|
||||||
|
|
||||||
(defn upsert-settlements
|
(defn upsert-settlements
|
||||||
([client]
|
([client]
|
||||||
@@ -419,7 +419,7 @@
|
|||||||
:client (:client/code client)}
|
: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))
|
||||||
@(dc/transact conn x))
|
@(dc/transact-async conn x))
|
||||||
(log/info "Done loading settlements"))))
|
(log/info "Done loading settlements"))))
|
||||||
|
|
||||||
(defn upsert-refunds
|
(defn upsert-refunds
|
||||||
@@ -433,7 +433,7 @@
|
|||||||
:location (:square-location/client-location client)}
|
:location (:square-location/client-location client)}
|
||||||
(doseq [x (partition-all 20 (refunds client location))]
|
(doseq [x (partition-all 20 (refunds client location))]
|
||||||
(log/info "Loading refund" (count x))
|
(log/info "Loading refund" (count x))
|
||||||
@(dc/transact conn x))
|
@(dc/transact-async conn x))
|
||||||
(log/info "Done loading refunds"))))
|
(log/info "Done loading refunds"))))
|
||||||
|
|
||||||
(def square-read [:db/id
|
(def square-read [:db/id
|
||||||
@@ -474,7 +474,7 @@
|
|||||||
[(:square-location/square-id sl)
|
[(:square-location/square-id sl)
|
||||||
(:db/id sl)])
|
(:db/id sl)])
|
||||||
(:client/square-locations client)))]
|
(:client/square-locations client)))]
|
||||||
@(dc/transact conn (for [square-location (client-locations client)]
|
@(dc/transact-async conn (for [square-location (client-locations client)]
|
||||||
{:db/id (or (square-id->id (:id square-location)) (random-tempid))
|
{:db/id (or (square-id->id (:id square-location)) (random-tempid))
|
||||||
:client/_square-locations (:db/id client)
|
:client/_square-locations (:db/id client)
|
||||||
:square-location/name (:name square-location)
|
:square-location/name (:name square-location)
|
||||||
@@ -492,7 +492,7 @@
|
|||||||
(map (fn [x] [:db/retractEntity x]))))
|
(map (fn [x] [:db/retractEntity x]))))
|
||||||
|
|
||||||
(defn mark-integration-status [client integration-status]
|
(defn mark-integration-status [client integration-status]
|
||||||
@(dc/transact conn
|
@(dc/transact-async conn
|
||||||
[{:db/id (:db/id client)
|
[{:db/id (:db/id client)
|
||||||
:client/square-integration-status (assoc integration-status
|
:client/square-integration-status (assoc integration-status
|
||||||
:db/id (or (-> client :client/square-integration-status :db/id)
|
:db/id (or (-> client :client/square-integration-status :db/id)
|
||||||
|
|||||||
@@ -568,7 +568,7 @@
|
|||||||
(doseq [x (partition-all 100 results)]
|
(doseq [x (partition-all 100 results)]
|
||||||
(log/info ::loading-orders
|
(log/info ::loading-orders
|
||||||
:count (count x))
|
:count (count x))
|
||||||
@(dc/transact conn x))))))))
|
@(dc/transact-async conn x))))))))
|
||||||
|
|
||||||
|
|
||||||
(defn upsert-settlements
|
(defn upsert-settlements
|
||||||
@@ -588,7 +588,7 @@
|
|||||||
(doseq [x (partition-all 20 settlements)]
|
(doseq [x (partition-all 20 settlements)]
|
||||||
(log/info ::loading-deposits
|
(log/info ::loading-deposits
|
||||||
:count (count x))
|
:count (count x))
|
||||||
@(dc/transact conn x))
|
@(dc/transact-async conn x))
|
||||||
(log/info ::done-loading-deposits)))))))
|
(log/info ::done-loading-deposits)))))))
|
||||||
|
|
||||||
(defn upsert-refunds
|
(defn upsert-refunds
|
||||||
@@ -609,7 +609,7 @@
|
|||||||
(log/info ::loading-refunds
|
(log/info ::loading-refunds
|
||||||
:count (count x)
|
:count (count x)
|
||||||
:sample (first x))
|
:sample (first x))
|
||||||
@(dc/transact conn x))
|
@(dc/transact-async conn x))
|
||||||
|
|
||||||
(catch Throwable e
|
(catch Throwable e
|
||||||
(log/error ::upsert-refunds-failed
|
(log/error ::upsert-refunds-failed
|
||||||
@@ -687,7 +687,7 @@
|
|||||||
(log/info ::loading-cash-shifts
|
(log/info ::loading-cash-shifts
|
||||||
:count (count x)
|
:count (count x)
|
||||||
:sample (first x))
|
:sample (first x))
|
||||||
@(dc/transact conn x))
|
@(dc/transact-async conn x))
|
||||||
|
|
||||||
(catch Throwable e
|
(catch Throwable e
|
||||||
(log/error ::upsert-cash-shifts-failed
|
(log/error ::upsert-cash-shifts-failed
|
||||||
@@ -737,7 +737,7 @@
|
|||||||
(:client/square-locations client)))]
|
(:client/square-locations client)))]
|
||||||
(de/chain (client-locations client)
|
(de/chain (client-locations client)
|
||||||
(fn [client-locations]
|
(fn [client-locations]
|
||||||
@(dc/transact conn
|
@(dc/transact-async conn
|
||||||
(for [square-location client-locations]
|
(for [square-location client-locations]
|
||||||
{:db/id (or (square-id->id (:id square-location)) (str (java.util.UUID/randomUUID)))
|
{:db/id (or (square-id->id (:id square-location)) (str (java.util.UUID/randomUUID)))
|
||||||
:client/_square-locations (:db/id client)
|
:client/_square-locations (:db/id client)
|
||||||
@@ -756,7 +756,7 @@
|
|||||||
(map (fn [x] [:db/retractEntity x]))))
|
(map (fn [x] [:db/retractEntity x]))))
|
||||||
|
|
||||||
(defn mark-integration-status [client integration-status]
|
(defn mark-integration-status [client integration-status]
|
||||||
@(dc/transact conn
|
@(dc/transact-async conn
|
||||||
[{:db/id (:db/id client)
|
[{:db/id (:db/id client)
|
||||||
:client/square-integration-status (assoc integration-status
|
:client/square-integration-status (assoc integration-status
|
||||||
:db/id (or (-> client :client/square-integration-status :db/id)
|
:db/id (or (-> client :client/square-integration-status :db/id)
|
||||||
|
|||||||
Reference in New Issue
Block a user