Makes insights actually work
This commit is contained in:
@@ -64,23 +64,27 @@
|
||||
(assoc similar-transaction :score score)))
|
||||
|
||||
(defn similar->recommendation [txs client]
|
||||
(->> txs
|
||||
(reduce (fn [acc t]
|
||||
(-> acc
|
||||
(update-in [[(:db/id (:transaction/vendor t))
|
||||
(:db/id (:transaction-account/account (first (:transaction/accounts t))))]
|
||||
:count]
|
||||
(fnil inc 0))
|
||||
(update-in [[(:db/id (:transaction/vendor t))
|
||||
(:db/id (:transaction-account/account (first (:transaction/accounts t))))]
|
||||
:seen-by-client?]
|
||||
(fn [seen-by-client?] (or seen-by-client? (= (:db/id (:transaction/client t))
|
||||
client))))))
|
||||
{})
|
||||
(map (fn [[k v]]
|
||||
(-> k
|
||||
(conj (:count v))
|
||||
(conj (:seen-by-client? v)))))))
|
||||
(try
|
||||
(->> txs
|
||||
(reduce (fn [acc t]
|
||||
(-> acc
|
||||
(update-in [[(:db/id (:transaction/vendor t))
|
||||
(:db/id (:transaction-account/account (first (:transaction/accounts t))))]
|
||||
:count]
|
||||
(fnil inc 0))
|
||||
(update-in [[(:db/id (:transaction/vendor t))
|
||||
(:db/id (:transaction-account/account (first (:transaction/accounts t))))]
|
||||
:seen-by-client?]
|
||||
(fn [seen-by-client?] (or seen-by-client? (= (:db/id (:transaction/client t))
|
||||
client))))))
|
||||
{})
|
||||
(map (fn [[k v]]
|
||||
(-> k
|
||||
(conj (:count v))
|
||||
(conj (:seen-by-client? v))))))
|
||||
(catch Exception e
|
||||
(println e)
|
||||
[])))
|
||||
|
||||
(defn get-outcome-recommendations []
|
||||
(for [[transaction client] (get-recent-transactions)
|
||||
|
||||
Reference in New Issue
Block a user