Compare commits

..

2 Commits

Author SHA1 Message Date
284b9342ce Better param processing
Some checks failed
Compile and test using leiningen / Run tests (push) Has been cancelled
2026-01-17 02:16:39 +01:00
a09c0f86d5 Search matches by date 2026-01-17 02:01:17 +01:00
2 changed files with 22 additions and 19 deletions

View File

@@ -37,10 +37,6 @@
:max (:max params) :max (:max params)
:header (:header params))) :header (:header params)))
(defn to-epoch
[time]
(- (/ (System/currentTimeMillis) 1000) (* 60 60 24)))
(defn cmd-show-matches-adapter (defn cmd-show-matches-adapter
[params] [params]
(check-debug params) (check-debug params)
@@ -49,7 +45,10 @@
:lol (:lol params) :lol (:lol params)
:tft (:tft params) :tft (:tft params)
:format (:format params) :format (:format params)
:since (to-epoch (:since params)))) :since (:since params)
:until (:until params)
:max (:max params)
))
;;[player-name player-tag & {:keys [lol tft template continuous every-seconds max] ;;[player-name player-tag & {:keys [lol tft template continuous every-seconds max]
@@ -63,8 +62,8 @@
"--[no-]tft" {:doc "Check if playing TFT" :default true} "--[no-]tft" {:doc "Check if playing TFT" :default true}
"-t, --template <template>" {:doc "Text template"} "-t, --template <template>" {:doc "Text template"}
"-c, --[no-]continuous" {:doc "Print continuosly" :default false} "-c, --[no-]continuous" {:doc "Print continuosly" :default false}
"--period <seconds>" {:doc "If printing continuosly, period in seconds" :parse parse-long :default 60} "-p, --period <seconds>" {:doc "If printing continuosly, period in seconds" :parse parse-long :default 60}
"--max <max>" {:doc "If printing continuosly, max number of checks." :parse parse-long :default -1} "-m, --max <max>" {:doc "If printing continuosly, max number of checks." :parse parse-long :default -1}
"--[no-]header" {:doc "If true, print a header over each check" :default true}]} "--[no-]header" {:doc "If true, print a header over each check" :default true}]}
"matches <username> <usertag>" "matches <username> <usertag>"
@@ -73,7 +72,9 @@
:flags ["--[no-]lol" {:doc "Check if playing LOL" :default true} :flags ["--[no-]lol" {:doc "Check if playing LOL" :default true}
"--[no-]tft" {:doc "Check if playing TFT" :default true} "--[no-]tft" {:doc "Check if playing TFT" :default true}
"-f, --format <table|edn|csv>" {:doc "Output format" :parse keyword :default "table"} "-f, --format <table|edn|csv>" {:doc "Output format" :parse keyword :default "table"}
"-s, --since <time>" {:doc "Obtain registries since <time>" :default "today"}]} "-s, --since <time>" {:doc "Obtain registries since <time>"}
"-u, --until <time>" {:doc "Obtain registries until <time>"}
"-m, --max <max>" {:doc "Max number of registries for each game type"}]}
] ]
:flags ["-v, --verbose" "Increases verbosity" :flags ["-v, --verbose" "Increases verbosity"
"--debug-http" "Show HTTP request/response data" "--debug-http" "Show HTTP request/response data"

View File

@@ -67,20 +67,21 @@
(print "CSV")) (print "CSV"))
(defn get-matches (defn get-matches
[player-name player-tag & {:keys [lol tft since max] [player-name player-tag & {:keys [lol tft since until max]
:or {lol true :or {lol true
tft true tft true}
since "today"
max 10
}
:as params}] :as params}]
(let [millis (process-time-literal since)] (let [call-params (cond-> {}
(when @debug (println "Parsed date:" millis)) max (assoc :count max)
since (assoc :startTime (process-time-literal since))
until (assoc :endTime (process-time-literal until)))]
(when @debug (println "Params")
(pp/pprint call-params))
(cond-> [] (cond-> []
lol (concat (map get-lol-match-data lol (concat (map get-lol-match-data
(get-lol-matches (lol-get-uuid player-name player-tag) :count max :startTime millis))) (get-lol-matches (lol-get-uuid player-name player-tag) call-params)))
tft (concat (map get-tft-match-data tft (concat (map get-tft-match-data
(get-tft-matches (tft-get-uuid player-name player-tag) :count max :startTime millis)))))) (get-tft-matches (tft-get-uuid player-name player-tag) call-params))))))
(comment (comment
(get-matches "Walid Georgey" "EUW") (get-matches "Walid Georgey" "EUW")
@@ -88,7 +89,7 @@
(defn cmd-show-matches (defn cmd-show-matches
[player-name player-tag & {:keys [lol tft format since max] [player-name player-tag & {:keys [lol tft format since until max]
:or {lol true :or {lol true
tft true tft true
format :table format :table
@@ -108,5 +109,6 @@
(comment (comment
(set-riot-api-key :RIOT_DEV_KEY "RGAPI-9fcdee6d-620f-443e-959f-b43fc445f51b") (set-riot-api-key :RIOT_DEV_KEY "RGAPI-9fcdee6d-620f-443e-959f-b43fc445f51b")
(cmd-show-matches "Walid Georgey" "EUW")
(cmd-show-matches "Walid Georgey" "EUW" :since "yesterday" :max 2) (cmd-show-matches "Walid Georgey" "EUW" :since "yesterday" :max 2)
) )