should only have one arity with this thing.
This commit is contained in:
@@ -409,69 +409,71 @@
|
||||
|
||||
|
||||
|
||||
(defn do-import
|
||||
([]
|
||||
(do-import (client/get-transactions)))
|
||||
([transactions]
|
||||
(lc/with-context {:source "Import yodlee transactions"}
|
||||
(let [import-id (start-import :import-source/yodlee "Automated Yodlee User")]
|
||||
(lc/with-context {:import-id import-id}
|
||||
(try
|
||||
(log/info "importing from yodlee")
|
||||
(let [account-lookup (->> (d/q '[:find ?ya ?ba
|
||||
:in $
|
||||
:where [?ba :bank-account/yodlee-account-id ?ya]]
|
||||
(d/db conn))
|
||||
(into {}))
|
||||
transactions-by-bank-account (group-by
|
||||
#(account-lookup (:accountId %))
|
||||
transactions)
|
||||
result (->> transactions-by-bank-account
|
||||
(filter (fn [[bank-account]]
|
||||
bank-account))
|
||||
(map (fn [[bank-account transactions]]
|
||||
(import-for-bank-account transactions bank-account import-id)))
|
||||
aggregate-results)]
|
||||
|
||||
(defn import-yodlee [transactions]
|
||||
(lc/with-context {:source "Import yodlee transactions"}
|
||||
(let [import-id (start-import :import-source/yodlee "Automated Yodlee User")]
|
||||
(lc/with-context {:import-id import-id}
|
||||
(try
|
||||
(log/info "importing from yodlee")
|
||||
(let [account-lookup (->> (d/q '[:find ?ya ?ba
|
||||
:in $
|
||||
:where [?ba :bank-account/yodlee-account-id ?ya]]
|
||||
(d/db conn))
|
||||
(into {}))
|
||||
transactions-by-bank-account (group-by
|
||||
#(account-lookup (:accountId %))
|
||||
transactions)
|
||||
result (->> transactions-by-bank-account
|
||||
(filter (fn [[bank-account]]
|
||||
bank-account))
|
||||
(map (fn [[bank-account transactions]]
|
||||
(import-for-bank-account transactions bank-account import-id)))
|
||||
aggregate-results)]
|
||||
|
||||
|
||||
(finish-import (assoc result :db/id import-id)))
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
(finish-import {:db/id import-id})))))))
|
||||
|
||||
(defn do-import []
|
||||
(import-yodlee (client/get-transactions)))
|
||||
|
||||
(finish-import (assoc result :db/id import-id)))
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
(finish-import {:db/id import-id}))))))))
|
||||
(def do-import (allow-once do-import))
|
||||
|
||||
|
||||
(defn do-import2
|
||||
([]
|
||||
(log/info "starting import")
|
||||
(do-import2 (client2/get-transactions "NGGL")))
|
||||
([transactions]
|
||||
(lc/with-context {:source "Import yodlee2 transactions"}
|
||||
(let [import-id (start-import :import-source/yodlee "Automated Yodlee User")]
|
||||
(lc/with-context {:import-id import-id}
|
||||
(try
|
||||
(let [account-lookup (->> (d/q '[:find ?ya ?ba
|
||||
:in $
|
||||
:where
|
||||
[?ba :bank-account/yodlee-account ?y]
|
||||
[?y :yodlee-account/id ?ya]]
|
||||
(d/db conn))
|
||||
(into {}))
|
||||
transactions-by-bank-account (group-by
|
||||
#(account-lookup (:accountId %))
|
||||
transactions)
|
||||
result (->> transactions-by-bank-account
|
||||
(filter (fn [[bank-account]]
|
||||
bank-account))
|
||||
(map (fn [[bank-account transactions]]
|
||||
(import-for-bank-account transactions bank-account import-id)))
|
||||
aggregate-results)]
|
||||
|
||||
(defn import-yodlee2
|
||||
[transactions]
|
||||
(lc/with-context {:source "Import yodlee2 transactions"}
|
||||
(let [import-id (start-import :import-source/yodlee "Automated Yodlee User")]
|
||||
(lc/with-context {:import-id import-id}
|
||||
(try
|
||||
(let [account-lookup (->> (d/q '[:find ?ya ?ba
|
||||
:in $
|
||||
:where
|
||||
[?ba :bank-account/yodlee-account ?y]
|
||||
[?y :yodlee-account/id ?ya]]
|
||||
(d/db conn))
|
||||
(into {}))
|
||||
transactions-by-bank-account (group-by
|
||||
#(account-lookup (:accountId %))
|
||||
transactions)
|
||||
result (->> transactions-by-bank-account
|
||||
(filter (fn [[bank-account]]
|
||||
bank-account))
|
||||
(map (fn [[bank-account transactions]]
|
||||
(import-for-bank-account transactions bank-account import-id)))
|
||||
aggregate-results)]
|
||||
|
||||
|
||||
(finish-import (assoc result :db/id import-id)))
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
(finish-import {:db/id import-id}))))))))
|
||||
(finish-import (assoc result :db/id import-id)))
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
(finish-import {:db/id import-id})))))))
|
||||
|
||||
(defn do-import2 []
|
||||
(log/info "starting import")
|
||||
(import-yodlee2 (client2/get-transactions "NGGL")))
|
||||
|
||||
(def do-import2 (allow-once do-import2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user