Compare commits

..

2 Commits

Author SHA1 Message Date
3a2679040e Retrofit test changes from graph branch 2025-07-07 23:19:49 +02:00
a50cb8a3eb Take some changes from graph branch 2025-07-07 23:13:40 +02:00
8 changed files with 83 additions and 497 deletions

View File

@@ -69,68 +69,9 @@ FIXME: listing of options this app accepts.
... ...
### Graphs ### Any Other Sections
### That You Think
Posible ASCII art charts ### Might be Useful
#### Simple day
A one dimension diagram. Draw a tick each day the player has played
```
####### ### ###### ###########
------------------------------------------------------------------------------------------
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
june
```
#### Day and hour
The x axis represents days of month, while y axis represents hours of each day. A tick is drawed in the hour
when the player was playing.
```
23 |
22 |
21 |
20 |
19 | # #
18 | # # #
17 | # # # #
16 | #
15 | # # # #
14 | # # # #
13 | #
12 | # # # #
11 | # # # # #
10 | # # # #
09 | # #
08 |
07 |
06 |
05 |
04 |
03 |
02 |
01 |
00 |
------------------------------------------------------------------------------------------
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
june
```
## Interesting graphic and UI libraries
- Raster SVG: https://github.com/soulspace-org/cmp.batik
- Modify SVG graphics: https://github.com/stathissideris/dali
- Create Vega-lite SVG graphics: https://github.com/techascent/tech.viz
- Enhance CLI text: https://github.com/clj-commons/pretty?tab=readme-ov-file
- Universal UI: https://github.com/phronmophobic/membrane?tab=readme-ov-file
- Interesting libraries: https://www.clojure-toolbox.com/
## License ## License

View File

@@ -5,29 +5,17 @@
:license {:name "MIT" :license {:name "MIT"
:url "https://mit-license.org/"} :url "https://mit-license.org/"}
:dependencies [[org.clojure/clojure "1.11.1"] ;; Clojure itself :dependencies [[org.clojure/clojure "1.11.1"]
[clj-http/clj-http "2.0.0"] ;; HTTP client [clj-http/clj-http "2.0.0"]
[cheshire/cheshire "6.0.0"] ;; Convert to/from JSON [cheshire/cheshire "6.0.0"]
[slingshot/slingshot "0.12.2"] ;; Better exceptions for clj-http [slingshot/slingshot "0.12.2"]
;; [org.clojure/tools.cli "1.1.230"] ;; Parse params. NOT USED [org.clojure/tools.cli "1.1.230"]
[cli-matic/cli-matic "0.5.4"] ;; Parse params and make a nice CLI app [cli-matic/cli-matic "0.5.4"]
[buddy/buddy-core "1.12.0-430"] ;; Cipher data [buddy/buddy-core "1.12.0-430"]
[org.clojure/tools.namespace "1.5.0"] ;; Hot reload from REPL [org.clojure/tools.namespace "1.5.0"]
[lt.tokenmill/timewords "0.5.0"] ;; Parse dates and times in natural languaje [lt.tokenmill/timewords "0.5.0"]]
;;; LIBS FOR GRAPHS, SOME OF THEM WILL BE REMOVED IN THE FUTURE :plugins [[io.taylorwood/lein-native-image "0.3.1"]]
;[com.hypirion/clj-xchart "0.2.0"] ;; Graphs and charts
;[aerial.hanami "0.15.1"] ;; Parse vega-lite data and generate graphics
;[folcon/oz "1.6.0-alpha6.2"] ;; Parse vega and vega-lite
[metasoarous/oz "1.6.0-alpha36"] ;; Other version of Oz
;[metasoarous/oz "2.0.0-alpha5"] ;; Newer version of Oz
[incanter/incanter-charts "1.9.3"] ;; graphics with Incanter
;[hswick/jutsu "0.1.1"] ;; Wrapper para plotly
[techascent/tech.viz "6.00-beta-16-4"] ;; Vega-lite parser (https://github.com/techascent/tech.viz)
]
:plugins [[io.taylorwood/lein-native-image "0.3.1"]] ;; Compile to native using graal
:main ^:skip-aot riot.app :main ^:skip-aot riot.app
:target-path "target/%s" :target-path "target/%s"

View File

@@ -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
@@ -386,5 +383,4 @@
; Launch manually ; Launch manually
(-main) (-main)
(old-main) (old-main))
)

View File

@@ -33,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))
@@ -107,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
@@ -118,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
@@ -221,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))))
@@ -425,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
@@ -449,9 +447,9 @@
(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)

View File

@@ -33,12 +33,11 @@
(defn parse-localdate (defn parse-localdate
"Parse a yyyy-MM-dd date to java.time.LocalDate" "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-str (defn parse-date-str
[s] [s]
(localdate-to-date(parse-localdate s))) (localdate-to-date (parse-localdate s)))
(defn parse-date-epoch (defn parse-date-epoch
@@ -71,7 +70,7 @@
(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)))))
@@ -103,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))
)
@@ -120,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
@@ -144,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))))
)
@@ -156,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)))
)
@@ -168,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)))
)

View File

@@ -1,323 +0,0 @@
(ns riot.graph_experiments
(:use riot.data)
(:require ;[com.hypirion.clj-xchart :as c]
[clojure.pprint :as pprint]
[clojure.math :as m]
[clojure.core.matrix :as mtx])
(:require [incanter.core :as incanter]
[incanter.stats :as stats]
[incanter.charts :as charts]
[incanter.datasets :as datasets])
(:require [oz.core :as oz])
(:require [tech.viz.vega :as vega]))
;; ;;;; XCHART
;; ;; XY chart
;; (def xchart_xy
;; (c/xy-chart {"Expected rate" [(range 10) (range 10)]
;; "Actual rate" [(range 10) (map #(+ % (rand-int 5) -2) (range 10))]}))
;; (comment
;; (c/view xchart_xy))
;; ;;;; HANAMI
;; (comment
;; (hc/xform ht/point-chart
;; :UDATA "data/cars.json"
;; :X "Horsepower" :Y "Miles_per_Gallon" :COLOR "Origin"))
;;;; OZ
(def test-plot
{:data {:values
[{:time "18:00" :volume 10}
{:time "18:02" :volume 41}
{:time "18:07" :volume 192}
{:time "18:30" :volume 257}
{:time "19:00" :volume 300}]
:format {:parse {:time "date:'%H:%M'"}}}
:encoding {:x {:field "time" :type "temporal" :timeUnit "hoursminutes"}
:y {:field "volume" :type "quantitative"}}
:mark "point"})
;;; to compile and view in Clojure - Oz:
(comment
(do
(println "calling (oz/start-server!)")
(oz/start-server!)
(println "calling (oz/view!)")
(oz/view! test-plot)
(println "calling (Thread/sleep)")
(Thread/sleep 5000))
)
;;;; INCANTER
;; Simple histogram
(comment
(incanter/view (charts/histogram (stats/sample-normal 1000))))
;; Boxplot demo
(defn create-box-plot [data]
(let [box-plot (charts/box-plot data
:title "Box Plot Example"
:y-label "Values"
:x-label "Dataset")]
(incanter/view box-plot)))
(def sample-data [5, 7, 8, 9, 10, 14, 15, 21, 23, 23, 24, 26, 28, 30, 37])
(comment
(create-box-plot sample-data))
;; Scatter
(comment
(incanter/view (charts/scatter-plot :Sepal.Length :Sepal.Width
:data (datasets/get-dataset :iris)))
(clojure.pprint/pprint (datasets/get-dataset :iris)))
;; Scatter grouped
(comment
(incanter/view (charts/scatter-plot :Sepal.Length :Sepal.Width
:group-by :Species
:data (datasets/get-dataset :iris)
:legend true)))
;; Scatter matrix (too complicated)
(comment
(incanter/view (charts/scatter-plot-matrix
(datasets/get-dataset :iris)
:nbins 20
:group-by :Species))
(incanter/with-data (datasets/get-dataset :iris) (incanter/view (charts/scatter-plot-matrix :nbins 20 :group-by :Species)))
(incanter/view (charts/scatter-plot-matrix
(datasets/get-dataset :chick-weight)
:group-by :Diet
:nbins 20)))
;; Heatmaps
(comment
(defn f [x y] (incanter/sin (incanter/sqrt (mtx/add (incanter/sq x) (incanter/sq y)))))
(incanter/view (charts/heat-map f -10 10 -15 15))
(incanter/view (charts/heat-map f -10 10 -10 10 :color? false))
(incanter/view (charts/heat-map f 5 10 5 10 :include-zero? false))
)
;; Personalize a scatter
(def my-data '({:start 1751537581404,
:end 1751539178158,
:duration 1583,
:active false,
:game-type "lol",
:id "EUW1_7450441192",
:winner true}
{:start 1751489335800,
:end 1751491099813,
:duration 1748,
:active false,
:game-type "lol",
:id "EUW1_7450117155",
:winner true}
{:start 1751486177961,
:end 1751487764068,
:duration 1568,
:active false,
:game-type "lol",
:id "EUW1_7450048068",
:winner true}
{:start 1751484450321,
:end 1751485680510,
:duration 1201,
:active false,
:game-type "lol",
:id "EUW1_7450013510",
:winner true}
{:start 1751400380588,
:end 1751401545922,
:duration 1133,
:active false,
:game-type "lol",
:id "EUW1_7449129548",
:winner true}
{:start 1751398221584,
:end 1751399322722,
:duration 1020,
:active false,
:game-type "lol",
:id "EUW1_7449082553",
:winner false}
{:start 1751394541765,
:end 1751396611534,
:duration 2040,
:active false,
:game-type "lol",
:id "EUW1_7449005657",
:winner false}
{:start 1751388187077,
:end 1751390143357,
:duration 1937,
:active false,
:game-type "lol",
:id "EUW1_7448887620",
:winner true}
{:start 1751384103153,
:end 1751385903519,
:duration 1767,
:active false,
:game-type "lol",
:id "EUW1_7448818616",
:winner false}
{:start 1751363056183,
:end 1751364555063,
:duration 1462,
:active false,
:game-type "lol",
:id "EUW1_7448564681",
:winner false}))
(defn extract-date-millis
"Extract date from a long epoch timestamp in milliseconds"
[x]
;(java.util.Date. x)
(let [date (new java.util.Date x)]
(. (java.util.Date. (. date getYear) (. date getMonth) (. date getDay)) getTime)))
(defn extract-date
"Extract date from a long epoch timestamp in milliseconds"
[x]
;(java.util.Date. x)
(let [date (new java.util.Date x)]
(java.util.Date. (. date getYear) (. date getMonth) (. date getDay))))
(comment
(extract-date-millis 1751363056183)
(. (extract-date-millis 1751363056183) getTime)
)
(defn extract-hour
"Extract hour from a long epoch timestamp in milliseconds"
[x]
;(java.util.Date. x)
(let [date (new java.util.Date x)]
(. date getHours)))
(comment
(java.util.Date. 1751537581404)
(java.util.Date. 1751539178158)
(extract-hour 1751537581404)
(extract-hour 1751539178158)
)
(defn extract-active-hours-millis
[match]
(when (every? some? [ (:start match) (:end match)])
(let [d-ini (extract-date-millis (:start match))
d-end (extract-date-millis (:end match))
h-ini (extract-hour (:start match))
h-end (extract-hour (:end match))
game-type (:game-type match)
winner (:winner match)]
(if (= d-ini d-end)
(for [day [d-ini]
hour (range h-ini (inc h-end))]
[day hour game-type winner])
(concat
(for [day [d-ini]
hour (range h-ini 24)]
[day hour game-type winner])
(for [day [d-ini]
hour (range 0 (inc h-end))]
[day hour game-type winner]))))))
(defn extract-active-hours
[match]
(when (every? some? [(:start match) (:end match)])
(let [d-ini (extract-date (:start match))
d-end (extract-date (:end match))
h-ini (extract-hour (:start match))
h-end (extract-hour (:end match))
game-type (:game-type match)
winner (:winner match)]
(if (= d-ini d-end)
(for [day [d-ini]
hour (range h-ini (inc h-end))]
[day hour game-type winner])
(concat
(for [day [d-ini]
hour (range h-ini 24)]
[day hour game-type winner])
(for [day [d-ini]
hour (range 0 (inc h-end))]
[day hour game-type winner]))))))
(comment
(extract-active-hours-millis (first my-data))
(partition 4 (flatten (map extract-active-hours-millis my-data)))
)
(defn extract-dataset-millis
[matches]
(incanter/dataset
[:days :hours :game-type :winner]
(partition 4 (flatten (map extract-active-hours-millis matches)))))
(defn extract-dataset
[matches]
(incanter/dataset
[:days :hours :game-type :winner]
(partition 4 (flatten (map extract-active-hours matches)))))
(comment
(extract-dataset-millis my-data)
(extract-dataset my-data)
(incanter/view (charts/scatter-plot :days :hours
:data (extract-dataset-millis my-data)
:group-by :game-type
:x-label "Day"
:y-label "Hour"
:legend false))
)
(comment
(defn process-my-data [x y] (+ x y (m/random)))
(incanter/view (charts/heat-map process-my-data
-10 10 -15 15
:x-label "Day"
:y-label "Hour"
:z-label "Count"
:color? true
:include-zero? false))
)
;;;; tech.viz
(comment
(let [ my-graph (vega/scatterplot [{:a 1 :b 2} {:a 2 :b 3}] :a :b)]
(vega/vega->svg-file my-graph "timeseries.svg"))
)

View File

@@ -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,8 +229,7 @@
(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
@@ -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 *")
@@ -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))))
)

View File

@@ -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
@@ -118,7 +114,6 @@
(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))))))
)