-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/api/games/user
– nondeterministic, returning duplicates, missing results
#366
Comments
By removing the Recently |
+1: My app (Chess Stamps) using the |
Interesting @khgiddon, in my case I do get results but they're the wrong ones. Still, there's the common implication of Thankfully I don't have many games and my usecase is very simple. So my workaround is simple too. I just pull all my games regardless of (ns chess
(:require
[clojure.pprint :as pp]
[clojure.string :as s]
[clojure.java.io :as io]
[clj-http.client :as client]
[cheshire.core :as json]
[clj-time.core :as t]
[clj-time.coerce :as tc]))
(defn game->rating [game]
(let [{{:keys [white black]} :players} game]
(:rating (case (-> white :user :name) "Deltaway" white black))))
(defn game->date [game]
(->> game :createdAt tc/from-long ((juxt t/year t/month t/day)) (apply t/local-date) str))
(defn game-desired? [game]
(= "blitz" (:speed game)))
(def process-games
(comp
(map #(json/parse-string-strict % true))
(filter game-desired?)
(map #(str (game->date %) "," (game->rating %) "\n"))))
(defn download-ratings []
(let [url (str "https://lichess.org/api/games/user/Deltaway?rated=true&since=1709269200000&sort=dateAsc")
headers {"Authorization" "Bearer <TOKEN_REDACTED>" "Accept" "application/x-ndjson"}
response (client/get url {:headers headers :as :reader})]
(with-open [reader (:body response)
writer (io/writer "ratings.csv")]
(.write writer "date,rating\n")
(doseq [line (sequence process-games (line-seq reader))] (.write writer line)))))
(download-ratings) |
Endpoint under test:
In
restclient
format, for clarity:I expect slightly over 500 games returned, but I get back 900–1500 objects (the number varies with each run). Many of these are duplicates, for example I got five of game
I0iDZ1UZ
returned in the results. And when I filter out duplicates on my end I'm missing some games that I ought to see based on the results of game search on the web UI.It's possible I'm misunderstanding correct usage of the API—sorry if so!
The text was updated successfully, but these errors were encountered: