Makes insights actually work

This commit is contained in:
Bryce
2023-08-19 21:13:49 -07:00
parent 8a31112c5b
commit ecc31f3680
7 changed files with 128 additions and 87 deletions

View File

@@ -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)