Makes integreat run on datomic cloud

This commit is contained in:
2022-08-23 12:13:12 -07:00
parent 58b9dcf272
commit d02fba2b44
58 changed files with 2163 additions and 1257 deletions

View File

@@ -1,8 +1,10 @@
(ns auto-ap.datomic.clients
(:require
[auto-ap.datomic :refer [conn uri]]
[auto-ap.datomic :refer [conn]]
[auto-ap.search :as search]
[clj-time.coerce :as coerce]
[datomic.api :as d]))
[clojure.string :as str]
[datomic.client.api :as dc]))
(defn cleanse [e]
(-> e
@@ -27,7 +29,7 @@
(update :bank-account/sort-order (fn [so] (or so i)))))
(range) bas)))))
(defn get-all []
(->> (d/q '[:find (pull ?e [*
(->> (dc/q '[:find (pull ?e [*
{:client/square-integration-status [:integration-status/message
:integration-status/last-attempt
:integration-status/last-updated
@@ -56,14 +58,13 @@
{:plaid-item/_client [*]}
{:client/emails [:db/id :email-contact/email :email-contact/description]}])
:where [?e :client/name]]
(d/db (d/connect uri)))
(dc/db conn))
(map first)
(map cleanse)))
(defn get-by-id [id]
(->>
(d/pull (d/db conn )
(dc/pull (dc/db conn )
'[* {:client/bank-accounts [* {:bank-account/type [*]
:bank-account/yodlee-account [:yodlee-account/name :yodlee-account/id :yodlee-account/number]
:bank-account/intuit-bank-account [:intuit-bank-account/name :intuit-bank-account/external-id :db/id]
@@ -79,9 +80,28 @@
(defn code->id [code]
(->>
(d/query (-> {:query {:find ['?e]
(dc/q (-> {:query {:find ['?e]
:in ['$ '?code]
:where [['?e :client/code '?code ]]}
:args [(d/db (d/connect uri)) code]}))
:args [(dc/db conn) code]}))
(first)
(first)))
(defn best-match [identifier]
(first (search/search-ids {:q (str/replace identifier #"[\(\)\-/\*\]\[\#:\&]" " ")} "client")))
(defn exact-match [identifier]
(first (search/search-ids {:exact-match (str/upper-case identifier)} "client")))
(defn rebuild-search-index []
(search/full-index-query
(for [result (map first (dc/qseq '[:find (pull ?v [:client/name :client/matches :db/id])
:in $
:where [?v :client/code]]
(dc/db conn)))
match (conj (or (:client/matches result) [])
(:client/name result))]
{:id (:db/id result)
:text match
:exact-match (str/upper-case match)})
"client"))