Skip to content

Commit

Permalink
fix: sample query
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Sep 29, 2021
1 parent 5dee92f commit 68be42e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/main/frontend/db/query_dsl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,17 @@
(subs result 1 (dec (count result)))
result)
(when-let [query (query-wrapper query blocks?)]
(let [result (react/react-query repo
{:query query
:query-string query-string}
(cond->
{:use-cache? false}
sort-by
(assoc :transform-fn sort-by)))]
(if @sample
(do
(swap! result (fn [col] (take @sample (shuffle col))))
result)
result)))))))))
(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)]
(react/react-query repo
{:query query
:query-string query-string}
{:use-cache? false
:transform-fn transform-fn})))))))))

(defn custom-query
[repo query-m query-opts]
Expand Down

0 comments on commit 68be42e

Please sign in to comment.