Adds extra yodlee logging
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
(ns auto-ap.import.yodlee2
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn random-tempid]]
|
||||
[auto-ap.import.common :refer [wrap-integration]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core2 :as client2]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as dc]
|
||||
[digest :as di]))
|
||||
(:require [auto-ap.datomic :refer [conn random-tempid]]
|
||||
[auto-ap.import.common :refer [wrap-integration]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core2 :as client2]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as dc]
|
||||
[digest :as di]))
|
||||
|
||||
#_{:clj-kondo/ignore [:unresolved-var]}
|
||||
(defn yodlee->transaction [transaction use-date-instead-of-post-date?]
|
||||
@@ -48,6 +48,7 @@
|
||||
:text "Starting"
|
||||
:priority :low}
|
||||
nil)
|
||||
(alog/info ::starting-yodlee-import)
|
||||
(let [import-batch (t/start-import-batch :import-source/yodlee2 "Automated yodlee2 user")]
|
||||
(try
|
||||
(let [account-lookup (dc/q '[:find ?ya ?ba ?cd ?ud
|
||||
@@ -57,16 +58,17 @@
|
||||
[(get-else $ ?ba :bank-account/use-date-instead-of-post-date? false) ?ud]
|
||||
[?c :client/bank-accounts ?ba]
|
||||
[?c :client/code ?cd]
|
||||
[?y :yodlee-account/id ?ya]
|
||||
]
|
||||
[?y :yodlee-account/id ?ya]]
|
||||
(dc/db conn))]
|
||||
(doseq [[yodlee-account bank-account client-code use-date-instead-of-post-date?] account-lookup
|
||||
:let [_ (alog/info ::getting-transactions-for :code client-code)]
|
||||
transaction (wrap-integration #(client2/get-specific-transactions client-code yodlee-account)
|
||||
bank-account)]
|
||||
bank-account)]
|
||||
(t/import-transaction! import-batch (assoc (yodlee->transaction transaction use-date-instead-of-post-date?)
|
||||
:transaction/bank-account bank-account
|
||||
:transaction/client [:client/code client-code])))
|
||||
|
||||
(alog/info ::finished-import)
|
||||
(t/finish! import-batch))
|
||||
(statsd/event {:title "Yodlee2 import Finished"
|
||||
:text (pr-str (t/get-stats import-batch))
|
||||
@@ -74,12 +76,14 @@
|
||||
nil)
|
||||
|
||||
(catch Exception e
|
||||
(alog/error ::failed-import :error e)
|
||||
(t/fail! import-batch e)
|
||||
(statsd/event {:title "Yodlee2 import failed"
|
||||
:text (str e)
|
||||
:alert-type :warning
|
||||
:priority :normal}
|
||||
nil)))))
|
||||
nil)
|
||||
(Thread/sleep 10000)))))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user