Fixed cryptokitties loading/ordering
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
dc0d0b59cb
commit
553f2c0e01
|
@ -54,7 +54,7 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:load-kitties
|
:load-kitties
|
||||||
(fn [{db :db} [_ ids]]
|
(fn [{db :db} [_ ids]]
|
||||||
{:db db
|
{:db (update-in db [:collectibles] merge {ck (sorted-map-by >)})
|
||||||
:http-get-n (mapv (fn [id]
|
:http-get-n (mapv (fn [id]
|
||||||
{:url (str "https://api.cryptokitties.co/kitties/" id)
|
{:url (str "https://api.cryptokitties.co/kitties/" id)
|
||||||
:success-event-creator (fn [o]
|
:success-event-creator (fn [o]
|
||||||
|
@ -63,18 +63,19 @@
|
||||||
[:load-collectible-failure ck {id (http/parse-payload o)}])})
|
[:load-collectible-failure ck {id (http/parse-payload o)}])})
|
||||||
ids)}))
|
ids)}))
|
||||||
|
|
||||||
;; TODO(andrey) Each HTTP call will return up to 100 kitties. Maybe we need to implement some kind of paging later
|
|
||||||
(defmethod load-collectibles-fx ck [_ _ items-number address _]
|
(defmethod load-collectibles-fx ck [_ _ items-number address _]
|
||||||
{:http-get {:url (str "https://api.cryptokitties.co/kitties?offset=0&limit="
|
{:http-get-n (mapv (fn [offset]
|
||||||
items-number
|
{:url (str "https://api.cryptokitties.co/kitties?limit=20&offset="
|
||||||
"&owner_wallet_address="
|
offset
|
||||||
address
|
"&owner_wallet_address="
|
||||||
"&parents=false")
|
address
|
||||||
:success-event-creator (fn [o]
|
"&parents=false")
|
||||||
[:load-kitties (map :id (:kitties (http/parse-payload o)))])
|
:success-event-creator (fn [o]
|
||||||
:failure-event-creator (fn [o]
|
[:load-kitties (map :id (:kitties (http/parse-payload o)))])
|
||||||
[:load-collectibles-failure (http/parse-payload o)])
|
:failure-event-creator (fn [o]
|
||||||
:timeout-ms 10000}})
|
[:load-collectibles-failure (http/parse-payload o)])
|
||||||
|
:timeout-ms 10000})
|
||||||
|
(range 0 items-number 20))}) ;; Cryptokitties API limited to 20 items per request
|
||||||
|
|
||||||
;; Crypto Strikers
|
;; Crypto Strikers
|
||||||
(def strikers :STRK)
|
(def strikers :STRK)
|
||||||
|
|
Loading…
Reference in New Issue