prepare dashboard
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
[digest :as di]
|
||||
[manifold.deferred :as de]
|
||||
[manifold.executor :as ex]
|
||||
[clojure.string :as str]))
|
||||
[clojure.string :as str]
|
||||
[auto-ap.ezcater.core :as e]))
|
||||
|
||||
(defn get-plaid-accounts
|
||||
([db]
|
||||
@@ -84,6 +85,30 @@
|
||||
{"id" (:db/id result)
|
||||
"name" (:plaid-merchant/name result)}))))
|
||||
|
||||
(defn upsert-accounts []
|
||||
(try
|
||||
(doseq [[bank-account-id client-id external-id access-token] (get-plaid-accounts (dc/db conn))
|
||||
]
|
||||
|
||||
(try
|
||||
(let [accounts (p/get-accounts access-token)]
|
||||
@(dc/transact
|
||||
conn
|
||||
(for [a (:accounts accounts)]
|
||||
{:plaid-account/external-id (:account_id a)
|
||||
:plaid-account/balance (or (some-> a
|
||||
:balances
|
||||
:current
|
||||
double)
|
||||
0.0) }))
|
||||
)
|
||||
(catch Exception e
|
||||
(alog/warn ::couldnt-upsert-account :error e))))
|
||||
|
||||
|
||||
(catch Exception e
|
||||
(alog/warn ::couldnt-upsert-accounts :error e))))
|
||||
|
||||
(defn import-plaid-int []
|
||||
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
|
||||
end (atime/local-now)
|
||||
|
||||
Reference in New Issue
Block a user