removed old database stuff, just left what's needed for importing
This commit is contained in:
@@ -6,34 +6,8 @@
|
||||
[honeysql-postgres.helpers :as postgres-helpers]
|
||||
[auto-ap.db.utils :refer [clj->db kebab->snake db->clj get-conn query limited-companies] :as utils]))
|
||||
|
||||
(defn upsert! [row]
|
||||
(j/db-do-prepared (get-conn)
|
||||
(doto (sql/format (-> (helpers/insert-into :transactions)
|
||||
(helpers/values [row])
|
||||
(postgres-helpers/upsert (-> (postgres-helpers/on-conflict :id)
|
||||
|
||||
(postgres-helpers/do-update-set :post_date :status :check_id)
|
||||
(helpers/where [:<> :EXCLUDED.check_id nil])))))
|
||||
println)))
|
||||
|
||||
(def base-query (sql/build :select :*
|
||||
:from :transactions))
|
||||
|
||||
(defn get-all []
|
||||
(query base-query))
|
||||
(defn base-graphql [{:keys [company-id id]}]
|
||||
|
||||
(cond-> base-query
|
||||
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)])
|
||||
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])))
|
||||
|
||||
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 100}}]
|
||||
(query
|
||||
(cond-> (base-graphql args)
|
||||
#_#_(not (nil? sort-by) ) (add-sort-by sort-by asc)
|
||||
true (assoc :limit limit)
|
||||
start (assoc :offset start))))
|
||||
|
||||
(defn count-graphql [args]
|
||||
(:count (first (query
|
||||
(assoc (base-graphql args) :select [:%count.*])))))
|
||||
|
||||
Reference in New Issue
Block a user