Fixing export bugs with bad queries, improving performance.

This commit is contained in:
Bryce Covert
2020-04-26 08:20:07 -07:00
parent d799fc469d
commit b89b4a86c5
6 changed files with 54 additions and 47 deletions

View File

@@ -792,15 +792,18 @@
(defn apply-sort-3 [args results]
(let [sort-bys (or (:sort args) [])
length (count sort-bys)
comparator (fn [xs ys]
(or (->> (map vector sort-bys xs ys)
(map (fn [[{:keys [asc]} x y]]
(if asc
(compare x y)
(compare y x))))
(drop-while #(= 0 %))
first)
0))]
(reduce
(fn [_ i]
(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)))
0
(range length)))]
(sort comparator results )))
(defn apply-pagination [args results]