Add more advanced filtering methods
This commit is contained in:
parent
54c57e085a
commit
47d255a3e8
2 changed files with 48 additions and 8 deletions
|
|
@ -294,9 +294,11 @@
|
|||
:direction :desc})
|
||||
refresh-id (now)]
|
||||
(swap! state update-in [:section/posts :loading] conj refresh-id)
|
||||
(js/console.log :start-query (.toISOString (js/Date.)))
|
||||
(. (promise-all [(db/count ::db/posts)
|
||||
(db/transduce-cursor xform posts-cursor)])
|
||||
(then (fn [[total displayed-posts]]
|
||||
(js/console.log :end-query (.toISOString (js/Date.)))
|
||||
(swap! state update :section/posts #(-> (assoc % :total total)
|
||||
(assoc :displayed-posts displayed-posts)
|
||||
(update :loading disj refresh-id))))))))
|
||||
|
|
@ -382,20 +384,25 @@
|
|||
|
||||
(comment
|
||||
; query current results
|
||||
(-> @state :section/posts :displayed-posts)
|
||||
(->> (-> @state :section/posts :displayed-posts) (map :id) (take 4) (into #{}))
|
||||
|
||||
; run and time a query on the database
|
||||
(do
|
||||
(js/console.log :start (.toISOString (js/Date.)))
|
||||
(let [xform (comp (mapcat (j/get :tags))
|
||||
(let [xform (comp #_(mapcat (j/get :tags))
|
||||
#_(filter #(= "typescript" (j/get % :name)))
|
||||
(take 10))
|
||||
#_(take 10)
|
||||
(filter (fn [_]
|
||||
(< (rand) 0.1)) #_(comp #{"115534300206096276"} (j/get :id)))
|
||||
(map (j/get :id)))
|
||||
posts-cursor (db/open-cursor ::db/posts ::db/all)]
|
||||
(.. (db/transduce-cursor xform conj! (transient #{}) posts-cursor)
|
||||
(then persistent!)
|
||||
(then (fn [result]
|
||||
(js/console.log :end (.toISOString (js/Date.)))
|
||||
(js/console.log :accts result))))))
|
||||
(let [result (into (sorted-set) result)]
|
||||
(js/console.log :sorted (.toISOString (js/Date.)))
|
||||
(js/console.log :accts (count result))))))))
|
||||
)
|
||||
|
||||
(defn post [{:keys [post]}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue