added default sorting back in.

This commit is contained in:
Bryce Covert
2020-09-01 22:47:03 -07:00
parent 088d78830a
commit abfcb37078
6 changed files with 19 additions and 12 deletions

View File

@@ -789,7 +789,8 @@
(:sort args)))
(defn apply-sort-3 [args results]
(let [sort-bys (or (:sort args) [])
(let [sort-bys (conj (:sort args)
{:sort-key "default" :asc true})
length (count sort-bys)
comparator (fn [xs ys]
(reduce
@@ -797,6 +798,7 @@
(let [comparison (if (:asc (sort-bys i))
(compare (nth xs i) (nth ys i))
(compare (nth ys i) (nth xs i)))]
(if (not= 0 comparison)
(reduced comparison)
0)))

View File

@@ -4,7 +4,8 @@
[auto-ap.graphql.utils :refer [limited-clients]]
[auto-ap.utils :refer [dollars=]]
[clojure.set :refer [rename-keys]]
[clj-time.coerce :as c]))
[clj-time.coerce :as c]
[clojure.tools.logging :as log]))
(defn <-datomic [result]
(-> result
@@ -125,10 +126,11 @@
:args [check-number-like]})
true
(merge-query {:query {:find ['?base-date '?e]
:where ['[?e :payment/date ?base-date]]}}))]
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :payment/date ?sort-default]]}}))]
(log/info "query" query)
(cond->> query
true (d/query)
true (apply-sort-3 args)

View File

@@ -27,7 +27,7 @@
(defn raw-graphql-ids [db args]
(->> (doto (cond-> {:query {:find []
:in ['$]
:where ['[?e :invoice/invoice-number]]}
:where []}
:args [(d/db (d/connect uri))]}
(limited-clients (:id args))
@@ -118,8 +118,9 @@
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
args)
true
(merge-query {:query {:find ['?e]
:where ['[?e :invoice/client]]}}) )
(merge-query {:query {:find ['?sort-default '?e ]
:where ['[?e :invoice/client]
'[?e :invoice/date ?sort-default]]}}) )
(#(log/info %)))

View File

@@ -9,9 +9,9 @@
(defn raw-graphql-ids [db args]
(let [query (cond-> {:query {:find []
(let [query (cond-> {:query {:find ['?sort-default]
:in ['$ ]
:where []}
:where ['[?e :journal-entry/date ?sort-default]]}
:args [db]}
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]

View File

@@ -73,8 +73,8 @@
:args [(c/to-date (:end (:date-range args)))]})
true
(merge-query {:query {:find ['?base-date '?e]
:where ['[?e :sales-order/date ?base-date]]}}))]
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :sales-order/date ?sort-default]]}}))]
(cond->> query

View File

@@ -115,7 +115,9 @@
"status" ['[?e :transaction/status ?sort-status]]}
args)
true
(merge-query {:query {:find ['?e] :where ['[?e :transaction/id]]}}))]
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :transaction/id]
'[?e :transaction/date ?sort-default]]}}))]
(cond->> query
true (d/query)
true (apply-sort-3 args)