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