good s orting across the board.

This commit is contained in:
Bryce Covert
2019-05-04 20:05:35 -07:00
parent 1232033160
commit d63bb566dc
7 changed files with 42 additions and 38 deletions

View File

@@ -75,21 +75,24 @@
:args [(:location args)]})
true
(merge-query {:query {:find ['?e] :where ['[?e :journal-entry/date]]}}))]
(cond->> query
true (d/query)
(:sort-by args) (apply-sort-2 args)
true (apply-pagination args))))
(merge-query {:query {:find ['?base-date '?e] :where ['[?e :journal-entry/date ?base-date]]}}))]
(->> query
(d/query)
(apply-sort-2 args [:desc :asc])
(apply-pagination args))))
(defn graphql-results [ids db args]
(->> (d/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 [*]}
{:bank-account/type [*]}]}]}]
ids)
(map #(update % :journal-entry/date c/from-date))
(apply-sort args (some-> (:sort-by args) sort-fn))))
(let [results (->> (d/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 [*]}
{:bank-account/type [*]}]}]}]
ids)
(map #(update % :journal-entry/date c/from-date))
(group-by :db/id))]
(->> ids
(map results)
(map first))))
(defn get-graphql [args]
(let [db (d/db (d/connect uri))