more performance improvement.
This commit is contained in:
@@ -48,15 +48,23 @@
|
|||||||
sort-fn (sort-by sort-fn)
|
sort-fn (sort-by sort-fn)
|
||||||
(= (:asc args) false) (reverse)))
|
(= (:asc args) false) (reverse)))
|
||||||
|
|
||||||
|
(defn apply-sort-2 [args results ]
|
||||||
|
|
||||||
|
(let [comparator (if (= (:asc args) false)
|
||||||
|
(fn [x y] (compare y x))
|
||||||
|
(fn [x y] (compare x y)))]
|
||||||
|
(sort comparator results )))
|
||||||
|
|
||||||
(defn apply-pagination [args results]
|
(defn apply-pagination [args results]
|
||||||
|
|
||||||
{:ids (->> results
|
{:ids (->> results
|
||||||
(drop (:start args 0))
|
(drop (:start args 0))
|
||||||
(take (:count args 100))
|
(take (:count args 100))
|
||||||
(map first))
|
(map last))
|
||||||
:count (count results)})
|
:count (count results)})
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(let [query (cond-> {:query {:find ['?e]
|
(let [query (cond-> {:query {:find []
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where []}
|
:where []}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
@@ -92,10 +100,10 @@
|
|||||||
:args [(:original-id args)]})
|
:args [(:original-id args)]})
|
||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:where ['[?e :transaction/id]]}}))]
|
(merge-query {:query {:find ['?e] :where ['[?e :transaction/id]]}}))]
|
||||||
(cond->> query
|
(cond->> query
|
||||||
true (d/query)
|
true (d/query)
|
||||||
(:sort-by args) (apply-sort args second)
|
(:sort-by args) (apply-sort-2 args)
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db args]
|
||||||
|
|||||||
Reference in New Issue
Block a user