added default sorting back in.
This commit is contained in:
@@ -789,7 +789,8 @@
|
|||||||
(:sort args)))
|
(:sort args)))
|
||||||
|
|
||||||
(defn apply-sort-3 [args results]
|
(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)
|
length (count sort-bys)
|
||||||
comparator (fn [xs ys]
|
comparator (fn [xs ys]
|
||||||
(reduce
|
(reduce
|
||||||
@@ -797,6 +798,7 @@
|
|||||||
(let [comparison (if (:asc (sort-bys i))
|
(let [comparison (if (:asc (sort-bys i))
|
||||||
(compare (nth xs i) (nth ys i))
|
(compare (nth xs i) (nth ys i))
|
||||||
(compare (nth ys i) (nth xs i)))]
|
(compare (nth ys i) (nth xs i)))]
|
||||||
|
|
||||||
(if (not= 0 comparison)
|
(if (not= 0 comparison)
|
||||||
(reduced comparison)
|
(reduced comparison)
|
||||||
0)))
|
0)))
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[auto-ap.utils :refer [dollars=]]
|
[auto-ap.utils :refer [dollars=]]
|
||||||
[clojure.set :refer [rename-keys]]
|
[clojure.set :refer [rename-keys]]
|
||||||
[clj-time.coerce :as c]))
|
[clj-time.coerce :as c]
|
||||||
|
[clojure.tools.logging :as log]))
|
||||||
|
|
||||||
(defn <-datomic [result]
|
(defn <-datomic [result]
|
||||||
(-> result
|
(-> result
|
||||||
@@ -125,10 +126,11 @@
|
|||||||
:args [check-number-like]})
|
:args [check-number-like]})
|
||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?base-date '?e]
|
(merge-query {:query {:find ['?sort-default '?e]
|
||||||
:where ['[?e :payment/date ?base-date]]}}))]
|
:where ['[?e :payment/date ?sort-default]]}}))]
|
||||||
|
|
||||||
|
|
||||||
|
(log/info "query" query)
|
||||||
(cond->> query
|
(cond->> query
|
||||||
true (d/query)
|
true (d/query)
|
||||||
true (apply-sort-3 args)
|
true (apply-sort-3 args)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(->> (doto (cond-> {:query {:find []
|
(->> (doto (cond-> {:query {:find []
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where ['[?e :invoice/invoice-number]]}
|
:where []}
|
||||||
:args [(d/db (d/connect uri))]}
|
:args [(d/db (d/connect uri))]}
|
||||||
|
|
||||||
(limited-clients (:id args))
|
(limited-clients (:id args))
|
||||||
@@ -118,8 +118,9 @@
|
|||||||
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
||||||
args)
|
args)
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?e]
|
(merge-query {:query {:find ['?sort-default '?e ]
|
||||||
:where ['[?e :invoice/client]]}}) )
|
:where ['[?e :invoice/client]
|
||||||
|
'[?e :invoice/date ?sort-default]]}}) )
|
||||||
(#(log/info %)))
|
(#(log/info %)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
|
|
||||||
(let [query (cond-> {:query {:find []
|
(let [query (cond-> {:query {:find ['?sort-default]
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where []}
|
:where ['[?e :journal-entry/date ?sort-default]]}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
|
|
||||||
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]
|
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]
|
||||||
|
|||||||
@@ -73,8 +73,8 @@
|
|||||||
:args [(c/to-date (:end (:date-range args)))]})
|
:args [(c/to-date (:end (:date-range args)))]})
|
||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?base-date '?e]
|
(merge-query {:query {:find ['?sort-default '?e]
|
||||||
:where ['[?e :sales-order/date ?base-date]]}}))]
|
:where ['[?e :sales-order/date ?sort-default]]}}))]
|
||||||
|
|
||||||
|
|
||||||
(cond->> query
|
(cond->> query
|
||||||
|
|||||||
@@ -115,7 +115,9 @@
|
|||||||
"status" ['[?e :transaction/status ?sort-status]]}
|
"status" ['[?e :transaction/status ?sort-status]]}
|
||||||
args)
|
args)
|
||||||
true
|
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
|
(cond->> query
|
||||||
true (d/query)
|
true (d/query)
|
||||||
true (apply-sort-3 args)
|
true (apply-sort-3 args)
|
||||||
|
|||||||
Reference in New Issue
Block a user