more performance improvement.

This commit is contained in:
BC
2019-01-29 07:42:29 -08:00
parent 2d0b127b4a
commit ccee0fca8d

View File

@@ -48,15 +48,23 @@
sort-fn (sort-by sort-fn)
(= (: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]
{:ids (->> results
(drop (:start args 0))
(take (:count args 100))
(map first))
(map last))
:count (count results)})
(defn raw-graphql-ids [db args]
(let [query (cond-> {:query {:find ['?e]
(let [query (cond-> {:query {:find []
:in ['$ ]
:where []}
:args [db]}
@@ -92,10 +100,10 @@
:args [(:original-id args)]})
true
(merge-query {:query {:where ['[?e :transaction/id]]}}))]
(merge-query {:query {:find ['?e] :where ['[?e :transaction/id]]}}))]
(cond->> query
true (d/query)
(:sort-by args) (apply-sort args second)
(:sort-by args) (apply-sort-2 args)
true (apply-pagination args))))
(defn graphql-results [ids db args]