Everything should be migrated over great
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
(ns auto-ap.datomic.yodlee2
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields
|
||||
apply-pagination
|
||||
apply-sort-3
|
||||
conn
|
||||
merge-query
|
||||
pull-many
|
||||
query2]]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[clj-time.coerce :as c]
|
||||
[datomic.api :as dc]))
|
||||
|
||||
(def default-read '[* {:yodlee-provider-account/client [:client/code]}])
|
||||
|
||||
(defn <-datomic [x]
|
||||
(-> x (update :yodlee-provider-account/last-updated c/from-date)))
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
(let [valid-clients (extract-client-ids (:clients args)
|
||||
(:client-id args)
|
||||
(when (:client-code args)
|
||||
[:client/code (:client-code args)]))]
|
||||
(->> (cond-> {:query {:find []
|
||||
:in ['$ '[?xx ...]]
|
||||
:where ['[?e :yodlee-provider-account/id]
|
||||
'[?e :yodlee-provider-account/client ?xx]]}
|
||||
:args [db valid-clients]}
|
||||
|
||||
|
||||
(:client-id args)
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :yodlee-provider-account/client ?client-id]]}
|
||||
:args [ (:client-id args)]})
|
||||
|
||||
(:client-code args)
|
||||
(merge-query {:query {:in ['?client-code]
|
||||
:where ['[?e :yodlee-provider-account/client ?client-id]
|
||||
'[?client-id :client/code ?client-code]]}
|
||||
:args [ (:client-code args)]})
|
||||
|
||||
(:sort args) (add-sorter-fields {"status" ['[?e :yodlee-provider-account/status ?sort-status]]
|
||||
"last-updated" ['[?e :yodlee-provider-account/last-updated ?sort-last-updated]]}
|
||||
args)
|
||||
true
|
||||
(merge-query {:query {:find ['?e ]
|
||||
:where ['[?e :yodlee-provider-account/id]]}}) )
|
||||
|
||||
(query2)
|
||||
(apply-sort-3 args)
|
||||
(apply-pagination args))))
|
||||
|
||||
|
||||
(defn graphql-results [ids db _]
|
||||
(let [results (->> (pull-many db default-read ids)
|
||||
(group-by :db/id))]
|
||||
(->> ids
|
||||
(map results)
|
||||
(map first)
|
||||
(mapv <-datomic))))
|
||||
|
||||
|
||||
(defn get-graphql [args]
|
||||
(let [db (dc/db conn)
|
||||
{ids-to-retrieve :ids matching-count :count} (raw-graphql-ids db args)]
|
||||
[(->> (graphql-results ids-to-retrieve db args))
|
||||
matching-count]))
|
||||
|
||||
Reference in New Issue
Block a user