much better sorting.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.datomic.transaction-rules
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri merge-query apply-sort-2 apply-pagination add-sorter-field]]
|
||||
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields]]
|
||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||
[clojure.set :refer [rename-keys]]
|
||||
[clj-time.coerce :as c]))
|
||||
@@ -24,18 +24,17 @@
|
||||
:in ['$]
|
||||
:where []}
|
||||
:args [db]}
|
||||
(:sort-by args) (add-sorter-field {"client" ['[?e :transaction-rule/client ?c]
|
||||
'[?c :client/name ?sorter]]
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :transaction-rule/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
|
||||
"yodlee-merchant" ['[?e :transaction-rule/yodlee-merchant ?c]
|
||||
'[?c :yodlee-merchant/name ?sorter]]
|
||||
"bank-account" ['[?e :transaction-rule/bank-account ?c]
|
||||
'[?c :bank-account/name ?sorter]]
|
||||
"description" ['[?e :transaction-rule/description ?sorter]]
|
||||
"note" ['[?e :transaction-rule/note ?sorter]]
|
||||
"amount-lte" ['[?e :transaction-rule/amount-lte ?sorter]]
|
||||
"amount-gte" ['[?e :transaction-rule/amount-gte ?sorter]]
|
||||
}
|
||||
"yodlee-merchant" ['[?e :transaction-rule/yodlee-merchant ?ym]
|
||||
'[?ym :yodlee-merchant/name ?sort-yodlee-merchant]]
|
||||
"bank-account" ['[?e :transaction-rule/bank-account ?ba]
|
||||
'[?ba :bank-account/name ?sort-bank-account]]
|
||||
"description" ['[?e :transaction-rule/description ?sort-description]]
|
||||
"note" ['[?e :transaction-rule/note ?sort-note]]
|
||||
"amount-lte" ['[?e :transaction-rule/amount-lte ?sort-amount-lte]]
|
||||
"amount-gte" ['[?e :transaction-rule/amount-gte ?sort-amount-gte]]}
|
||||
args)
|
||||
|
||||
(limited-clients (:id args))
|
||||
@@ -55,7 +54,7 @@
|
||||
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
true (apply-sort-2 args [:asc])
|
||||
true (apply-sort-3 args)
|
||||
true (apply-pagination args))))
|
||||
|
||||
(defn graphql-results [ids db args]
|
||||
|
||||
Reference in New Issue
Block a user