Updates for events.
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
(ns auto-ap.import.intuit
|
||||
(:require [amazonica.aws.s3 :as s3]
|
||||
[auto-ap.datomic :refer [conn remove-nils]]
|
||||
[auto-ap.intuit.core :as i]
|
||||
[auto-ap.utils :refer [by allow-once]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clj-time.format :as f]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.intuit.core :as i]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
|
||||
(defn get-intuit-bank-accounts [db]
|
||||
(d/q '[:find ?external-id ?ba ?c
|
||||
@@ -39,6 +37,10 @@
|
||||
|
||||
(defn import-intuit []
|
||||
(lc/with-context {:source "Import intuit transactions"}
|
||||
(statsd/event {:title "Intuit import started"
|
||||
:text "Starting"
|
||||
:priority :low}
|
||||
nil)
|
||||
(let [import-batch (t/start-import-batch :import-source/intuit "Automated intuit user")
|
||||
db (d/db conn)
|
||||
end (auto-ap.time/local-now)
|
||||
@@ -51,8 +53,17 @@
|
||||
(intuits->transactions bank-account-id client-id))]
|
||||
(t/import-transaction! import-batch transaction))
|
||||
(t/finish! import-batch)
|
||||
(statsd/event {:title "Intuit import Finished"
|
||||
:text (pr-str (t/get-stats import-batch))
|
||||
:priority :low}
|
||||
nil)
|
||||
(catch Exception e
|
||||
(t/fail! import-batch e))))))
|
||||
(t/fail! import-batch e)
|
||||
(statsd/event {:title "Intuit import failed"
|
||||
:text (str e)
|
||||
:alert-type :warning
|
||||
:priority :normal}
|
||||
nil))))))
|
||||
|
||||
(def upsert-transactions (allow-once upsert-transactions))
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
(ns auto-ap.import.yodlee
|
||||
(:require [auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core :as client]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as d]
|
||||
[digest :refer [sha-256]]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]
|
||||
[clojure.tools.logging :as log]))
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core :as client]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as d]
|
||||
[digest :refer [sha-256]]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
|
||||
(defn yodlee->transaction [transaction]
|
||||
(let [{post-date :postDate
|
||||
@@ -44,6 +46,10 @@
|
||||
|
||||
(defn import-yodlee []
|
||||
(lc/with-context {:source "Import yodlee transactions"}
|
||||
(statsd/event {:title "Yodlee import started"
|
||||
:text "Starting"
|
||||
:priority :low}
|
||||
nil)
|
||||
(let [import-batch (t/start-import-batch :import-source/yodlee "Automated yodlee user")]
|
||||
(try
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?c
|
||||
@@ -62,8 +68,17 @@
|
||||
:transaction/client client-id)))
|
||||
|
||||
(t/finish! import-batch))
|
||||
(statsd/event {:title "Yodlee import Finished"
|
||||
:text (pr-str (t/get-stats import-batch))
|
||||
:priority :low}
|
||||
nil)
|
||||
(catch Exception e
|
||||
(t/fail! import-batch e))))))
|
||||
(t/fail! import-batch e)
|
||||
(statsd/event {:title "Yodlee import failed"
|
||||
:text (str e)
|
||||
:alert-type :warning
|
||||
:priority :normal}
|
||||
nil))))))
|
||||
|
||||
(def import-yodlee (allow-once import-yodlee))
|
||||
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
(ns auto-ap.import.yodlee2
|
||||
(:require [auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.import.yodlee :as y]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core2 :as client2]
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.import.yodlee :as y]
|
||||
[auto-ap.utils :refer [allow-once]]
|
||||
[auto-ap.yodlee.core2 :as client2]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
|
||||
(defn import-yodlee2 []
|
||||
(lc/with-context {:source "Import yodlee2 transactions"}
|
||||
(statsd/event {:title "Yodlee2 import started"
|
||||
:text "Starting"
|
||||
:priority :low}
|
||||
nil)
|
||||
(let [import-batch (t/start-import-batch :import-source/yodlee2 "Automated yodlee2 user")]
|
||||
(try
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?cd
|
||||
@@ -28,8 +34,18 @@
|
||||
:transaction/client [:client/code client-code])))
|
||||
|
||||
(t/finish! import-batch))
|
||||
(statsd/event {:title "Yodlee2 import Finished"
|
||||
:text (pr-str (t/get-stats import-batch))
|
||||
:priority :low}
|
||||
nil)
|
||||
|
||||
(catch Exception e
|
||||
(t/fail! import-batch e))))))
|
||||
(t/fail! import-batch e)
|
||||
(statsd/event {:title "Yodlee2 import failed"
|
||||
:text (str e)
|
||||
:alert-type :warning
|
||||
:priority :normal}
|
||||
nil))))))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user