User can set up sales queries on their own now.
This commit is contained in:
@@ -41,17 +41,27 @@
|
||||
(into [(d/db conn)] (clojure.edn/read-string (get query-params "args" "[]")))))))))
|
||||
|
||||
|
||||
(defn put-query [id body note]
|
||||
(s3/put-object :bucket-name (:data-bucket env)
|
||||
:key (str "queries/" id)
|
||||
:input-stream (io/make-input-stream (.getBytes body) {})
|
||||
:metadata {:content-type "application/text"
|
||||
:user-metadata {:note note}})
|
||||
{:body {:query body
|
||||
:id id
|
||||
:results-url (str "/api/queries/" id "/results")
|
||||
:csv-results-url (str "/api/queries/" id "/results/csv")
|
||||
:json-results-url (str "/api/queries/" id "/results/json")}})
|
||||
(defn put-query [guid body note & [lookup-key client]]
|
||||
(let [guid (if lookup-key
|
||||
(or (:saved-query/guid (d/pull (d/db conn) [:saved-query/guid] [:saved-query/lookup-key lookup-key]))
|
||||
guid)
|
||||
guid)]
|
||||
@(d/transact conn [(cond->
|
||||
{:saved-query/guid guid
|
||||
:saved-query/description note
|
||||
:saved-query/key (str "queries/" guid)}
|
||||
client (assoc :saved-query/client client)
|
||||
lookup-key (assoc :saved-query/lookup-key lookup-key))])
|
||||
(s3/put-object :bucket-name (:data-bucket env)
|
||||
:key (str "queries/" guid)
|
||||
:input-stream (io/make-input-stream (.getBytes body) {})
|
||||
:metadata {:content-type "application/text"
|
||||
:user-metadata {:note note}})
|
||||
{:body {:query body
|
||||
:id guid
|
||||
:results-url (str "/api/queries/" guid "/results")
|
||||
:csv-results-url (str "/api/queries/" guid "/results/csv")
|
||||
:json-results-url (str "/api/queries/" guid "/results/json")}}))
|
||||
|
||||
(def json-routes
|
||||
(context "/queries" []
|
||||
|
||||
Reference in New Issue
Block a user