Makes integreat run on datomic cloud
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
(ns auto-ap.datomic.ledger
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||
[auto-ap.datomic :refer [merge-query apply-sort-3 apply-pagination add-sorter-fields conn]]
|
||||
[clj-time.coerce :as c]
|
||||
[auto-ap.datomic.accounts :as d-accounts]))
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields
|
||||
apply-pagination
|
||||
apply-sort-3
|
||||
conn
|
||||
merge-query
|
||||
pull-many]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||
[clj-time.coerce :as c]
|
||||
[datomic.client.api :as dc]))
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
(let [query (cond-> {:query {:find []
|
||||
@@ -120,12 +127,12 @@
|
||||
true
|
||||
(merge-query {:query {:find ['?sort-default '?e] :where ['[?e :journal-entry/date ?sort-default]]}}))]
|
||||
(->> query
|
||||
(d/query)
|
||||
(dc/q)
|
||||
(apply-sort-3 (update args :sort conj {:sort-key "default-2" :asc true}))
|
||||
(apply-pagination args))))
|
||||
|
||||
(defn graphql-results [ids db _]
|
||||
(let [results (->> (d/pull-many db '[* {:journal-entry/client [:client/name :client/code :db/id]
|
||||
(let [results (->> (pull-many db '[* {:journal-entry/client [:client/name :client/code :db/id]
|
||||
:journal-entry/vendor [:vendor/name :db/id]
|
||||
:journal-entry/line-items [* {:journal-entry-line/account [*
|
||||
{:account/type [*]}
|
||||
@@ -154,7 +161,7 @@
|
||||
(map first))))
|
||||
|
||||
(defn get-graphql [args]
|
||||
(let [db (d/db conn)
|
||||
(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]))
|
||||
@@ -164,8 +171,8 @@
|
||||
(->> {:query {:find ['?e]
|
||||
:in ['$ '[?e ...]]
|
||||
:where ['[?e :journal-entry/date]]}
|
||||
:args [(d/db conn) ids]}
|
||||
(d/query)
|
||||
:args [(dc/db conn) ids]}
|
||||
(dc/q)
|
||||
(map first)
|
||||
vec)
|
||||
[]))
|
||||
|
||||
Reference in New Issue
Block a user