fix: disable reactive query in api/q

This commit is contained in:
Tienson Qin
2023-04-12 23:48:01 +08:00
parent cb7e1321c0
commit 86c5376eb8
2 changed files with 22 additions and 17 deletions

View File

@@ -587,22 +587,26 @@ Some bindings in this fn:
(defn query
"Runs a dsl query with query as a string. Primary use is from '{{query }}'"
[repo query-string]
(when (and (string? query-string) (not= "\"\"" query-string))
(let [{:keys [query rules sort-by blocks? sample]} (parse-query query-string)]
(when-let [query' (some-> query (query-wrapper {:blocks? blocks?}))]
(let [sort-by (or sort-by identity)
random-samples (if @sample
(fn [col]
(take @sample (shuffle col)))
identity)
transform-fn (comp sort-by random-samples)]
(query-react/react-query repo
{:query query'
:query-string query-string
:rules rules}
{:use-cache? false
:transform-fn transform-fn}))))))
([repo query-string]
(query repo query-string {}))
([repo query-string query-opts]
(when (and (string? query-string) (not= "\"\"" query-string))
(let [{:keys [query rules sort-by blocks? sample]} (parse-query query-string)]
(when-let [query' (some-> query (query-wrapper {:blocks? blocks?}))]
(let [sort-by (or sort-by identity)
random-samples (if @sample
(fn [col]
(take @sample (shuffle col)))
identity)
transform-fn (comp sort-by random-samples)]
(query-react/react-query repo
{:query query'
:query-string query-string
:rules rules}
(merge
{:use-cache? false
:transform-fn transform-fn}
query-opts))))))))
(defn custom-query
"Runs a dsl query with query as a seq. Primary use is from advanced query"