Compare commits
2 Commits
e9064f9b61
...
v1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a2679040e | |||
| a50cb8a3eb |
@@ -13,8 +13,7 @@
|
|||||||
[cli-matic/cli-matic "0.5.4"]
|
[cli-matic/cli-matic "0.5.4"]
|
||||||
[buddy/buddy-core "1.12.0-430"]
|
[buddy/buddy-core "1.12.0-430"]
|
||||||
[org.clojure/tools.namespace "1.5.0"]
|
[org.clojure/tools.namespace "1.5.0"]
|
||||||
[lt.tokenmill/timewords "0.5.0"]
|
[lt.tokenmill/timewords "0.5.0"]]
|
||||||
[com.hypirion/clj-xchart "0.2.0"]]
|
|
||||||
|
|
||||||
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
|
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@
|
|||||||
(get-puuid-from-params (get-lol-api-key) [] :name "Errepunto" :tag "4595")
|
(get-puuid-from-params (get-lol-api-key) [] :name "Errepunto" :tag "4595")
|
||||||
|
|
||||||
(get-puuid-from-params (get-tft-api-key) [] :puuid "annlAfxhJnTwlwRgQZYbGeQpD3jWb-ju7vVKEW_g-EIJf6xQT0eeb-0obARVekrksf8n9XCjcxyHHQ")
|
(get-puuid-from-params (get-tft-api-key) [] :puuid "annlAfxhJnTwlwRgQZYbGeQpD3jWb-ju7vVKEW_g-EIJf6xQT0eeb-0obARVekrksf8n9XCjcxyHHQ")
|
||||||
(get-puuid-from-params (get-tft-api-key) [] :name "Errepunto" :tag "4595")
|
(get-puuid-from-params (get-tft-api-key) [] :name "Errepunto" :tag "4595"))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -55,8 +54,7 @@
|
|||||||
|
|
||||||
(comment
|
(comment
|
||||||
(cmd-active :_arguments ["annlAfxhJnTwlwRgQZYbGeQpD3jWb-ju7vVKEW_g-EIJf6xQT0eeb-0obARVekrksf8n9XCjcxyHHQ"])
|
(cmd-active :_arguments ["annlAfxhJnTwlwRgQZYbGeQpD3jWb-ju7vVKEW_g-EIJf6xQT0eeb-0obARVekrksf8n9XCjcxyHHQ"])
|
||||||
(cmd-active :_arguments ["Errepunto" "4595"])
|
(cmd-active :_arguments ["Errepunto" "4595"]))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@
|
|||||||
(take count)
|
(take count)
|
||||||
(format-dates-cond format-dates format-durations date-format)
|
(format-dates-cond format-dates format-durations date-format)
|
||||||
(filter-columns show-columns)
|
(filter-columns show-columns)
|
||||||
(map )
|
(map)
|
||||||
(format-map output))))
|
(format-map output))))
|
||||||
(catch [:status 401] _
|
(catch [:status 401] _
|
||||||
(U/exit! "Invalid API key" 3))
|
(U/exit! "Invalid API key" 3))
|
||||||
@@ -155,30 +153,29 @@
|
|||||||
(defn cmd-bulk
|
(defn cmd-bulk
|
||||||
"Get all matches"
|
"Get all matches"
|
||||||
[& {:keys [lol-api-key tft-api-key output format-dates format-durations date-format reverse order-by show-columns debug-http since until _arguments]
|
[& {:keys [lol-api-key tft-api-key output format-dates format-durations date-format reverse order-by show-columns debug-http since until _arguments]
|
||||||
:as opts}]
|
:as opts}]
|
||||||
(try+
|
(try+
|
||||||
;(println "Get timeline" opts)
|
;(println "Get timeline" opts)
|
||||||
(let [lol-key (get-lol-api-key lol-api-key)
|
(let [lol-key (get-lol-api-key lol-api-key)
|
||||||
tft-key (get-tft-api-key tft-api-key)
|
tft-key (get-tft-api-key tft-api-key)
|
||||||
lol-id (get-puuid-from-params lol-key _arguments opts)
|
lol-id (get-puuid-from-params lol-key _arguments opts)
|
||||||
tft-id (get-puuid-from-params tft-key _arguments opts)]
|
tft-id (get-puuid-from-params tft-key _arguments opts)]
|
||||||
;(println "LOL API key" lol-key "TFT API key" tft-key)
|
;(println "LOL API key" lol-key "TFT API key" tft-key)
|
||||||
(if (or (nil? lol-id) (nil? tft-id))
|
(if (or (nil? lol-id) (nil? tft-id))
|
||||||
(U/exit! "Invalid params" 2)
|
(U/exit! "Invalid params" 2)
|
||||||
(->> (get-matches-info-batch lol-id tft-id :lol-api-key lol-key :tft-api-key tft-key :debug debug-http :order-by (keyword order-by) :since (get-date since) :until (get-date until))
|
(->> (get-matches-info-batch lol-id tft-id :lol-api-key lol-key :tft-api-key tft-key :debug debug-http :order-by (keyword order-by) :since (get-date since) :until (get-date until))
|
||||||
(reverse-cond reverse)
|
(reverse-cond reverse)
|
||||||
(format-dates-cond format-dates format-durations date-format)
|
(format-dates-cond format-dates format-durations date-format)
|
||||||
(filter-columns show-columns)
|
(filter-columns show-columns)
|
||||||
(format-map output))))
|
(format-map output))))
|
||||||
(catch [:status 401] _
|
(catch [:status 401] _
|
||||||
(U/exit! "Invalid API key" 3))
|
(U/exit! "Invalid API key" 3))
|
||||||
(catch [:status 404] _
|
(catch [:status 404] _
|
||||||
(U/exit! "Unknown user or tag" 5))
|
(U/exit! "Unknown user or tag" 5))
|
||||||
(catch [:status 429] _
|
(catch [:status 429] _
|
||||||
(U/exit! "Rate limit exceeded, please wait some minutes and try again" 4))
|
(U/exit! "Rate limit exceeded, please wait some minutes and try again" 4))
|
||||||
(catch [:status 503] _
|
(catch [:status 503] _
|
||||||
(U/exit! "Server timeout, please wait some minutes and try again" 6))
|
(U/exit! "Server timeout, please wait some minutes and try again" 6))))
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
;; More info: https://github.com/l3nz/cli-matic/blob/master/README.md
|
;; More info: https://github.com/l3nz/cli-matic/blob/master/README.md
|
||||||
@@ -223,8 +220,8 @@
|
|||||||
:type :string :default nil
|
:type :string :default nil
|
||||||
:as "Summoner tagline"}]
|
:as "Summoner tagline"}]
|
||||||
:runs cmd-active}
|
:runs cmd-active}
|
||||||
{:command "timeline" :short "t"
|
{:command "last" :short "l"
|
||||||
:description ["Gets times from last played matches"
|
:description ["Gets time info from last matches."
|
||||||
"You can search by PUUID or name and tagline, but not both."
|
"You can search by PUUID or name and tagline, but not both."
|
||||||
""
|
""
|
||||||
"You can set the PUUID passing only one argument or using -p param."
|
"You can set the PUUID passing only one argument or using -p param."
|
||||||
@@ -292,7 +289,7 @@
|
|||||||
:as ["Ending date (not included) in 'yyyy-MM-dd' format."
|
:as ["Ending date (not included) in 'yyyy-MM-dd' format."
|
||||||
"Other valid values: today, yesterday, tomorrow"]}]
|
"Other valid values: today, yesterday, tomorrow"]}]
|
||||||
:runs cmd-timeline}
|
:runs cmd-timeline}
|
||||||
{:command "bulk" :short "b"
|
{:command "timeline" :short "t"
|
||||||
:description ["Get info from LOL and TFT matches in a time range."
|
:description ["Get info from LOL and TFT matches in a time range."
|
||||||
"Warning: it can take several minutes to obtain all data, due to api restrictions."
|
"Warning: it can take several minutes to obtain all data, due to api restrictions."
|
||||||
"You can search by PUUID or name and tagline, but not both."
|
"You can search by PUUID or name and tagline, but not both."
|
||||||
@@ -386,5 +383,4 @@
|
|||||||
; Launch manually
|
; Launch manually
|
||||||
(-main)
|
(-main)
|
||||||
|
|
||||||
(old-main)
|
(old-main))
|
||||||
)
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
;; Core functions to get data from server
|
;; Core functions to get data from server
|
||||||
|
|
||||||
(ns riot.core
|
(ns riot.core
|
||||||
(:import [java.time Instant LocalDateTime ZoneId]
|
|
||||||
[java.net URLEncoder])
|
|
||||||
(:require [clj-http.client :as client]
|
(:require [clj-http.client :as client]
|
||||||
[buddy.core.crypto :as crypto]
|
[buddy.core.crypto :as crypto]
|
||||||
[buddy.core.codecs :as codecs])
|
[buddy.core.codecs :as codecs])
|
||||||
@@ -35,7 +33,7 @@
|
|||||||
|
|
||||||
;;;; API KEYS
|
;;;; API KEYS
|
||||||
|
|
||||||
(def DEV_KEY "RGAPI-e068aea3-5828-48e2-9500-259ef96c8c4f")
|
(def DEV_KEY "RGAPI-fc8c6d88-2c13-4a43-b53f-3465bb564acc")
|
||||||
(def LOL_KEY "jXL+gA3LIeBPBvrOhLOYSZCiURC7eOtwMXahkxtwpdj6JDtT5NMu25zMz+UY2+9MuHBADjUJh46jSanrV5OBag==")
|
(def LOL_KEY "jXL+gA3LIeBPBvrOhLOYSZCiURC7eOtwMXahkxtwpdj6JDtT5NMu25zMz+UY2+9MuHBADjUJh46jSanrV5OBag==")
|
||||||
(def TFT_KEY (encrypt-data DEV_KEY secret-key iv))
|
(def TFT_KEY (encrypt-data DEV_KEY secret-key iv))
|
||||||
|
|
||||||
@@ -109,8 +107,7 @@
|
|||||||
(get-in riot.test-examples/response-lol-match [:info :participants 3])
|
(get-in riot.test-examples/response-lol-match [:info :participants 3])
|
||||||
|
|
||||||
(get-player-info riot.test-examples/response-lol-match riot.test-examples/example-lol-puuid)
|
(get-player-info riot.test-examples/response-lol-match riot.test-examples/example-lol-puuid)
|
||||||
(winner? riot.test-examples/response-lol-match riot.test-examples/example-lol-puuid)
|
(winner? riot.test-examples/response-lol-match riot.test-examples/example-lol-puuid))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(defn with-winner-status
|
(defn with-winner-status
|
||||||
@@ -120,8 +117,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(with-winner-status riot.test-examples/matches-example riot.test-examples/example-lol-puuid)
|
(with-winner-status riot.test-examples/matches-example riot.test-examples/example-lol-puuid))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; json adapters
|
;; json adapters
|
||||||
@@ -143,7 +139,7 @@
|
|||||||
(make-json-data [:none] :game-type (constantly "ftf"))
|
(make-json-data [:none] :game-type (constantly "ftf"))
|
||||||
(make-json-data [:metadata :match_id] :id)
|
(make-json-data [:metadata :match_id] :id)
|
||||||
(make-json-data [:none] :winner (constantly false))]
|
(make-json-data [:none] :winner (constantly false))]
|
||||||
:post #(post-calculate-win
|
:post #(post-calculate-win
|
||||||
(post-calculate-end %1 %2 %3) %2 %3)}) ; end = start + (duration * 1000)
|
(post-calculate-end %1 %2 %3) %2 %3)}) ; end = start + (duration * 1000)
|
||||||
|
|
||||||
(def lol-current-parser {:parser [(make-json-data [:gameStartTime] :start)
|
(def lol-current-parser {:parser [(make-json-data [:gameStartTime] :start)
|
||||||
@@ -223,7 +219,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn date-to-seconds
|
(defn date-to-seconds
|
||||||
([] (date-to-seconds (java.util.Date. )))
|
([] (date-to-seconds (java.util.Date.)))
|
||||||
([d]
|
([d]
|
||||||
(when (some? d) (quot (.getTime d) 1000))))
|
(when (some? d) (quot (.getTime d) 1000))))
|
||||||
|
|
||||||
@@ -361,7 +357,7 @@
|
|||||||
server1 "europe"
|
server1 "europe"
|
||||||
server2 "euw1"
|
server2 "euw1"
|
||||||
count 20
|
count 20
|
||||||
start 0
|
start 0
|
||||||
order-by :start}}]
|
order-by :start}}]
|
||||||
(sort-by order-by
|
(sort-by order-by
|
||||||
(filter some?
|
(filter some?
|
||||||
@@ -427,9 +423,9 @@
|
|||||||
debug false}}]
|
debug false}}]
|
||||||
(when (every? some? [puuid api-key])
|
(when (every? some? [puuid api-key])
|
||||||
(get-batch-range #(get-lol-matches puuid :api-key api-key :start (* count %) :since since :until until :server server :wait-limit-exceeded wait-limit-exceeded :debug debug :count count)
|
(get-batch-range #(get-lol-matches puuid :api-key api-key :start (* count %) :since since :until until :server server :wait-limit-exceeded wait-limit-exceeded :debug debug :count count)
|
||||||
:wait-limit-exceeded wait-limit-exceeded
|
:wait-limit-exceeded wait-limit-exceeded
|
||||||
:first-batch first-batch
|
:first-batch first-batch
|
||||||
:max-batches max-batches)))
|
:max-batches max-batches)))
|
||||||
|
|
||||||
|
|
||||||
(defn get-matches-batch-tft
|
(defn get-matches-batch-tft
|
||||||
@@ -448,12 +444,12 @@
|
|||||||
:max-batches max-batches)))
|
:max-batches max-batches)))
|
||||||
|
|
||||||
|
|
||||||
(defn get-matches-info-batch-lol
|
(defn get-matches-info-batch-lol
|
||||||
"Get a lot of LOL matches info"
|
"Get a lot of LOL matches info"
|
||||||
[matches-id puuid api-key & {:keys [server wait-limit-exceeded debug]
|
[matches-id puuid api-key & {:keys [server wait-limit-exceeded debug]
|
||||||
:or {server "europe"
|
:or {server "europe"
|
||||||
wait-limit-exceeded 15
|
wait-limit-exceeded 15
|
||||||
debug false}}]
|
debug false}}]
|
||||||
;; (println "Matches: " matches-id)
|
;; (println "Matches: " matches-id)
|
||||||
(when (every? some? [matches-id puuid api-key])
|
(when (every? some? [matches-id puuid api-key])
|
||||||
(get-batch-seq #(get-lol-match-info % :puuid puuid :api-key api-key :server server :wait-limit-exceeded wait-limit-exceeded :debug debug)
|
(get-batch-seq #(get-lol-match-info % :puuid puuid :api-key api-key :server server :wait-limit-exceeded wait-limit-exceeded :debug debug)
|
||||||
|
|||||||
@@ -31,14 +31,18 @@
|
|||||||
(java.util.Date/from (.toInstant (.atZone (.atStartOfDay localdate) (ZoneId/systemDefault))))))
|
(java.util.Date/from (.toInstant (.atZone (.atStartOfDay localdate) (ZoneId/systemDefault))))))
|
||||||
|
|
||||||
(defn parse-localdate
|
(defn parse-localdate
|
||||||
"Parse a yyyy-MM-dd date to java.util.Date"
|
"Parse a yyyy-MM-dd date to java.time.LocalDate"
|
||||||
[s]
|
[s]
|
||||||
(java.time.LocalDate/parse s (DateTimeFormatter/ofPattern DEFAULT_DATE_FORMAT))
|
(java.time.LocalDate/parse s (DateTimeFormatter/ofPattern DEFAULT_DATE_FORMAT)))
|
||||||
)
|
|
||||||
|
|
||||||
(defn parse-date
|
(defn parse-date-str
|
||||||
[s]
|
[s]
|
||||||
(localdate-to-date(parse-localdate s)))
|
(localdate-to-date (parse-localdate s)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn parse-date-epoch
|
||||||
|
[millis]
|
||||||
|
(localdate-to-date (unix-to-datetime millis)))
|
||||||
|
|
||||||
|
|
||||||
(defn format-datetime
|
(defn format-datetime
|
||||||
@@ -64,9 +68,9 @@
|
|||||||
"Converts a duration in seconds to a string with hours and seconds"
|
"Converts a duration in seconds to a string with hours and seconds"
|
||||||
[seconds]
|
[seconds]
|
||||||
(when (some? seconds)
|
(when (some? seconds)
|
||||||
(if (< seconds 3600)
|
(if (< seconds 3600)
|
||||||
(format "%02d:%02d" (quot seconds 60) (rem seconds 60))
|
(format "%02d:%02d" (quot seconds 60) (rem seconds 60))
|
||||||
(format "%02d:%02d:%02d" (quot seconds 3600) ( - ( quot seconds 60) 60) (rem seconds 60)))))
|
(format "%02d:%02d:%02d" (quot seconds 3600) (- (quot seconds 60) 60) (rem seconds 60)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -82,8 +86,8 @@
|
|||||||
|
|
||||||
A match has been played today if its start date or end date is from today"
|
A match has been played today if its start date or end date is from today"
|
||||||
[match]
|
[match]
|
||||||
(or
|
(or
|
||||||
(>= (or (:start match) 0) (today-millis))
|
(>= (or (:start match) 0) (today-millis))
|
||||||
(>= (or (:end match) 0) (today-millis))))
|
(>= (or (:end match) 0) (today-millis))))
|
||||||
|
|
||||||
|
|
||||||
@@ -98,8 +102,7 @@
|
|||||||
(map #(update % :start (fn [x] (format-datetime-millis x datetime-format))))
|
(map #(update % :start (fn [x] (format-datetime-millis x datetime-format))))
|
||||||
(map #(update % :end (fn [x] (format-datetime-millis x datetime-format))))))
|
(map #(update % :end (fn [x] (format-datetime-millis x datetime-format))))))
|
||||||
(comment
|
(comment
|
||||||
(with-parsed-dates riot.test-examples/matches-example)
|
(with-parsed-dates riot.test-examples/matches-example))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -115,9 +118,8 @@
|
|||||||
[matches & {:keys [datetime-format]
|
[matches & {:keys [datetime-format]
|
||||||
:or {datetime-format DEFAULT_DATE_TIME_FORMAT}}]
|
:or {datetime-format DEFAULT_DATE_TIME_FORMAT}}]
|
||||||
(-> matches
|
(-> matches
|
||||||
(with-parsed-durations)
|
(with-parsed-durations)
|
||||||
(with-parsed-dates :datetime-format datetime-format)
|
(with-parsed-dates :datetime-format datetime-format)))
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Export to other formats
|
;;; Export to other formats
|
||||||
@@ -139,8 +141,7 @@
|
|||||||
|
|
||||||
(comment
|
(comment
|
||||||
(println (as-json (with-parsed-dates-durations riot.test-examples/matches-example
|
(println (as-json (with-parsed-dates-durations riot.test-examples/matches-example
|
||||||
:pretty false)))
|
:pretty false))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -151,8 +152,7 @@
|
|||||||
|
|
||||||
(comment
|
(comment
|
||||||
(as-ascii-table riot.test-examples/matches-example)
|
(as-ascii-table riot.test-examples/matches-example)
|
||||||
(as-ascii-table (with-parsed-dates-durations riot.test-examples/matches-example))
|
(as-ascii-table (with-parsed-dates-durations riot.test-examples/matches-example)))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -163,12 +163,11 @@
|
|||||||
(str/join (System/lineSeparator) ; Local EOL characteres
|
(str/join (System/lineSeparator) ; Local EOL characteres
|
||||||
(concat
|
(concat
|
||||||
[(clojure.string/join separator (map name (keys (first matches))))] ; header
|
[(clojure.string/join separator (map name (keys (first matches))))] ; header
|
||||||
(map #(clojure.string/join separator %)
|
(map #(clojure.string/join separator %)
|
||||||
(map vals matches))))))
|
(map vals matches))))))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(as-csv riot.test-examples/matches-example)
|
(as-csv riot.test-examples/matches-example)
|
||||||
(as-csv riot.test-examples/matches-example2)
|
(as-csv riot.test-examples/matches-example2)
|
||||||
(as-csv (with-parsed-dates-durations riot.test-examples/matches-example))
|
(as-csv (with-parsed-dates-durations riot.test-examples/matches-example))
|
||||||
(as-csv (with-parsed-dates-durations riot.test-examples/matches-example2))
|
(as-csv (with-parsed-dates-durations riot.test-examples/matches-example2)))
|
||||||
)
|
|
||||||
|
|||||||
@@ -126,8 +126,7 @@
|
|||||||
(testing "Some dates"
|
(testing "Some dates"
|
||||||
(is (nil? (date-to-seconds nil)))
|
(is (nil? (date-to-seconds nil)))
|
||||||
(is (some? (date-to-seconds)))
|
(is (some? (date-to-seconds)))
|
||||||
(is (= 1738364400 (date-to-seconds (java.util.Date. 125 1 1)))))
|
(is (= 1738364400 (date-to-seconds (java.util.Date. 125 1 1))))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; Get parameter for querying data
|
;; Get parameter for querying data
|
||||||
@@ -230,10 +229,9 @@
|
|||||||
(is (not res) (str "Oh, well, the player is playing: " res))))
|
(is (not res) (str "Oh, well, the player is playing: " res))))
|
||||||
(testing "Include current"
|
(testing "Include current"
|
||||||
(let [res (is-playing? example-lol-puuid example-tft-puuid)]
|
(let [res (is-playing? example-lol-puuid example-tft-puuid)]
|
||||||
(is (not res) (str "Oh, well, the player is playing: " res)))))
|
(is (not res) (str "Oh, well, the player is playing: " res))))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(deftest test-get-matches-batch-lol
|
(deftest test-get-matches-batch-lol
|
||||||
(println "* Get lol matches batch *")
|
(println "* Get lol matches batch *")
|
||||||
(testing "Invalid data"
|
(testing "Invalid data"
|
||||||
@@ -241,7 +239,7 @@
|
|||||||
(is (= nil (get-matches-batch-lol example-lol-puuid nil)))
|
(is (= nil (get-matches-batch-lol example-lol-puuid nil)))
|
||||||
(is (= nil (get-matches-batch-lol nil (get-lol-api-key)))))
|
(is (= nil (get-matches-batch-lol nil (get-lol-api-key)))))
|
||||||
(testing "Get LOL matches"
|
(testing "Get LOL matches"
|
||||||
(is (= 10 (count (get-matches-batch-lol example-lol-puuid (get-lol-api-key):count 5 :max-batches 2))))))
|
(is (= 10 (count (get-matches-batch-lol example-lol-puuid (get-lol-api-key) :count 5 :max-batches 2))))))
|
||||||
|
|
||||||
(deftest test-get-matches-batch-tft
|
(deftest test-get-matches-batch-tft
|
||||||
(println "* Get tft matches batch *")
|
(println "* Get tft matches batch *")
|
||||||
@@ -252,7 +250,7 @@
|
|||||||
(testing "Get LOL matches"
|
(testing "Get LOL matches"
|
||||||
(is (= 10 (count (get-matches-batch-tft example-tft-puuid (get-tft-api-key) :count 5 :max-batches 2))))))
|
(is (= 10 (count (get-matches-batch-tft example-tft-puuid (get-tft-api-key) :count 5 :max-batches 2))))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-get-matches-info-batch-lol
|
(deftest test-get-matches-info-batch-lol
|
||||||
(println "* Get lol matches info batch *")
|
(println "* Get lol matches info batch *")
|
||||||
(testing "Invalid data"
|
(testing "Invalid data"
|
||||||
@@ -298,5 +296,4 @@
|
|||||||
(get-matches-info-batch example-lol-puuid example-tft-puuid)
|
(get-matches-info-batch example-lol-puuid example-tft-puuid)
|
||||||
(catch [:status 404] {:keys [request-time headers body] :as excp}
|
(catch [:status 404] {:keys [request-time headers body] :as excp}
|
||||||
(println "NOT Found 404")
|
(println "NOT Found 404")
|
||||||
(pp/pprint excp)))
|
(pp/pprint excp))))
|
||||||
)
|
|
||||||
|
|||||||
@@ -58,8 +58,7 @@
|
|||||||
(testing "Long durations"
|
(testing "Long durations"
|
||||||
(is (= "01:00:00" (format-duration-seconds 3600)))
|
(is (= "01:00:00" (format-duration-seconds 3600)))
|
||||||
(is (= "01:00:01" (format-duration-seconds 3601)))
|
(is (= "01:00:01" (format-duration-seconds 3601)))
|
||||||
(is (= "01:01:01" (format-duration-seconds 3661))))
|
(is (= "01:01:01" (format-duration-seconds 3661)))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; Epoch in millis for today at 00:00:00 hours. Difficult to test
|
;; Epoch in millis for today at 00:00:00 hours. Difficult to test
|
||||||
@@ -77,8 +76,7 @@
|
|||||||
(is (match-today? {:start (+ 5000 (today-millis))})))
|
(is (match-today? {:start (+ 5000 (today-millis))})))
|
||||||
(testing "End date today"
|
(testing "End date today"
|
||||||
(is (match-today? {:end (today-millis)}))
|
(is (match-today? {:end (today-millis)}))
|
||||||
(is (match-today? {:end (+ 5000 (today-millis))})))
|
(is (match-today? {:end (+ 5000 (today-millis))}))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; Parse dates inside a lis of matches
|
;; Parse dates inside a lis of matches
|
||||||
@@ -90,8 +88,7 @@
|
|||||||
(is (= '({:a "AAA" :b 2 :start nil, :end nil}) (with-parsed-dates '({:a "AAA" :b 2})))))
|
(is (= '({:a "AAA" :b 2 :start nil, :end nil}) (with-parsed-dates '({:a "AAA" :b 2})))))
|
||||||
(testing "Valid list"
|
(testing "Valid list"
|
||||||
(is (= '({:start "2025-06-11 19:00:54", :end nil, :duration 1288, :active true, :game-type "lol", :id "EUW1_111111"})
|
(is (= '({:start "2025-06-11 19:00:54", :end nil, :duration 1288, :active true, :game-type "lol", :id "EUW1_111111"})
|
||||||
(with-parsed-dates (take 1 matches-example))))
|
(with-parsed-dates (take 1 matches-example))))))
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
;; Parse durations
|
;; Parse durations
|
||||||
@@ -103,8 +100,7 @@
|
|||||||
(is (= '({:a "AAA" :b 2 :duration nil}) (with-parsed-durations '({:a "AAA" :b 2})))))
|
(is (= '({:a "AAA" :b 2 :duration nil}) (with-parsed-durations '({:a "AAA" :b 2})))))
|
||||||
(testing "Valid list"
|
(testing "Valid list"
|
||||||
(is (= '({:start 1749661254854, :end nil, :duration "21:28", :active true, :game-type "lol", :id "EUW1_111111"})
|
(is (= '({:start 1749661254854, :end nil, :duration "21:28", :active true, :game-type "lol", :id "EUW1_111111"})
|
||||||
(with-parsed-durations (take 1 matches-example)))))
|
(with-parsed-durations (take 1 matches-example))))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; Parse dates and durations
|
;; Parse dates and durations
|
||||||
@@ -112,13 +108,12 @@
|
|||||||
(println "* Parse dates and durations in a match list *")
|
(println "* Parse dates and durations in a match list *")
|
||||||
(testing "Empty or invalid lists"
|
(testing "Empty or invalid lists"
|
||||||
(is (= '() (with-parsed-dates-durations '())))
|
(is (= '() (with-parsed-dates-durations '())))
|
||||||
(is (= '({:duration nil, :start nil, :end nil})
|
(is (= '({:duration nil, :start nil, :end nil})
|
||||||
(with-parsed-dates-durations '({}))))
|
(with-parsed-dates-durations '({}))))
|
||||||
(is (= '({:a "AAA" :b 2 :duration nil, :start nil, :end nil})
|
(is (= '({:a "AAA" :b 2 :duration nil, :start nil, :end nil})
|
||||||
(with-parsed-dates-durations '({:a "AAA" :b 2})))))
|
(with-parsed-dates-durations '({:a "AAA" :b 2})))))
|
||||||
(testing "Valid list"
|
(testing "Valid list"
|
||||||
(is (= '({:start "2025-06-11 19:00:54", :end nil, :duration "21:28", :active true, :game-type "lol", :id "EUW1_111111"})
|
(is (= '({:start "2025-06-11 19:00:54", :end nil, :duration "21:28", :active true, :game-type "lol", :id "EUW1_111111"})
|
||||||
(with-parsed-dates-durations (take 1 matches-example)))))
|
(with-parsed-dates-durations (take 1 matches-example))))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user