pagination.

This commit is contained in:
Bryce Covert
2018-04-13 15:16:37 -07:00
parent 330a276f60
commit 121a38f20d
5 changed files with 139 additions and 64 deletions

View File

@@ -71,12 +71,23 @@
q)))
(defn get-graphql [{:keys [imported company-id sort-by asc]}]
(defn base-graphql [{:keys [imported company-id]}]
(cond-> base-query
(not (nil? imported)) (helpers/merge-where [:= :imported imported])
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])
))
(defn get-graphql [{:keys [start sort-by asc] :as args}]
(query
(cond-> base-query
(not (nil? imported)) (helpers/merge-where [:= :imported imported])
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])
(not (nil? sort-by) ) (add-sort-by sort-by asc))))
(cond-> (base-graphql args)
(not (nil? sort-by) ) (add-sort-by sort-by asc)
true (assoc :limit 20)
start (assoc :offset start))))
(defn count-graphql [args]
(:count (first (query
(assoc (base-graphql args) :select [:%count.*])))))
(defn import [parsed-invoices companies vendors]
(insert-multi!