good s orting across the board.
This commit is contained in:
@@ -33,9 +33,7 @@
|
||||
'[?v :vendor/name ?sorter]]
|
||||
"bank-account" ['[?e :payment/bank-account ?c]
|
||||
'[?c :bank-account/name ?sorter]]
|
||||
"check-number" ['(or-join [?e ?sorter]
|
||||
[?e :payment/check-number ?sorter]
|
||||
[(ground "" ?sorter)])]
|
||||
"check-number" ['[?e :payment/check-number ?sorter]]
|
||||
"date" ['[?e :payment/date ?sorter]]
|
||||
"amount" ['[?e :payment/amount ?sorter]]
|
||||
"status" ['[?e :payment/status ?sorter]]}
|
||||
@@ -113,7 +111,7 @@
|
||||
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
true (apply-sort-2 args)
|
||||
true (apply-sort-2 args [:desc :asc])
|
||||
true (apply-pagination args))))
|
||||
|
||||
(defn graphql-results [ids db args]
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
(merge-query {:query {:find ['?base-date '?e]
|
||||
:where ['[?e :invoice/date ?base-date]]}}) )
|
||||
(d/query)
|
||||
(apply-sort-2 args)
|
||||
(apply-sort-2 args [:asc :asc])
|
||||
(apply-pagination args)))
|
||||
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
'[?e :transaction/date ?base-date]]}}))]
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
true (apply-sort-2 args)
|
||||
true (apply-sort-2 args [:desc :asc])
|
||||
true (apply-pagination args))))
|
||||
|
||||
(defn graphql-results [ids db args]
|
||||
|
||||
Reference in New Issue
Block a user