a bunch of cleanup to remove stuff

This commit is contained in:
2023-10-14 23:37:04 -07:00
parent f997c41abd
commit 3d9d02f76a
15 changed files with 33 additions and 801 deletions

View File

@@ -4,23 +4,6 @@
[datomic.api :as dc]
[datomic.api :as d]))
(defn add-arg [query name value where & rest]
(let [query (-> query
(update :args conj value)
(update-in [:query :in] conj name)
(update-in [:query :where] conj where))]
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
(defn get-by-id [id]
(->> [(dc/pull (dc/db conn)
'[*
{:user/clients [*]}
{:user/role [:db/ident]}]
id)]
(map #(update % :user/role :db/ident))
first))
(defn find-or-insert! [{:keys [:user/provider :user/provider-id ] :as new-user}]
(let [is-first-user? (not (seq (dc/q [:find '?e
:in '$
@@ -43,30 +26,3 @@
user-id)
:user/role :db/ident)))
(defn raw-graphql [_]
(->> (dc/q {:find ['(pull ?e [*
{:user/clients [*]}
{:user/role [:db/ident]}])]
:in ['$]
:where ['[?e :user/role]]}
(dc/db conn))
(map first)
(map #(update % :user/role :db/ident))
))
(defn sort-fn [args]
(cond
(= "client" (:sort-by args))
#(-> % :payment/client :client/name)
:else
(keyword "payment" (:sort-by args))))
(defn get-graphql [args]
(let [results (raw-graphql args)]
(cond->> results
(:sort-by args) (sort-by (sort-fn args))
(= (:asc args) false) (reverse)
true (drop (:start args 0))
true (take (:count args 500)))))