added smaller test data and started setting up the serving of htmx via axum.

This commit is contained in:
Steven 2023-08-04 16:54:38 -04:00
parent 37eacffaef
commit a87ae3dcd3
3 changed files with 182 additions and 102 deletions

View file

@ -51,12 +51,12 @@
"usd_value": "7.67" "usd_value": "7.67"
}, },
{ {
"name": "spark double", "name": "aetherflux reservoir",
"count": 1, "count": 1,
"usd_value": "7.65" "usd_value": "7.43"
}, },
{ {
"name": "aetherflux reservoir", "name": "spectator seating",
"count": 1, "count": 1,
"usd_value": "7.43" "usd_value": "7.43"
}, },
@ -70,11 +70,6 @@
"count": 1, "count": 1,
"usd_value": "66.78" "usd_value": "66.78"
}, },
{
"name": "spectator seating",
"count": 1,
"usd_value": "6.89"
},
{ {
"name": "command beacon", "name": "command beacon",
"count": 1, "count": 1,
@ -93,7 +88,7 @@
{ {
"name": "vanquisher's banner", "name": "vanquisher's banner",
"count": 1, "count": 1,
"usd_value": "6.31" "usd_value": "6.15"
}, },
{ {
"name": "deserted beach", "name": "deserted beach",
@ -110,6 +105,11 @@
"count": 1, "count": 1,
"usd_value": "6.02" "usd_value": "6.02"
}, },
{
"name": "spark double",
"count": 1,
"usd_value": "5.84"
},
{ {
"name": "jaheira, friend of the forest", "name": "jaheira, friend of the forest",
"count": 1, "count": 1,
@ -138,7 +138,7 @@
{ {
"name": "avacyn, angel of hope", "name": "avacyn, angel of hope",
"count": 1, "count": 1,
"usd_value": "44.25" "usd_value": "41.87"
}, },
{ {
"name": "unnatural growth", "name": "unnatural growth",
@ -188,7 +188,7 @@
{ {
"name": "deflecting swat", "name": "deflecting swat",
"count": 1, "count": 1,
"usd_value": "38.03" "usd_value": "38.19"
}, },
{ {
"name": "fury", "name": "fury",
@ -215,6 +215,11 @@
"count": 2, "count": 2,
"usd_value": "3.92" "usd_value": "3.92"
}, },
{
"name": "ghalta, primal hunger",
"count": 1,
"usd_value": "3.88"
},
{ {
"name": "michiko konda, truth seeker", "name": "michiko konda, truth seeker",
"count": 1, "count": 1,
@ -225,11 +230,6 @@
"count": 1, "count": 1,
"usd_value": "3.81" "usd_value": "3.81"
}, },
{
"name": "ghalta, primal hunger",
"count": 1,
"usd_value": "3.77"
},
{ {
"name": "rolling earthquake", "name": "rolling earthquake",
"count": 1, "count": 1,
@ -308,7 +308,7 @@
{ {
"name": "finale of devastation", "name": "finale of devastation",
"count": 1, "count": 1,
"usd_value": "25.41" "usd_value": "24.06"
}, },
{ {
"name": "esper sentinel", "name": "esper sentinel",
@ -325,21 +325,16 @@
"count": 1, "count": 1,
"usd_value": "2.81" "usd_value": "2.81"
}, },
{
"name": "ugin, the ineffable",
"count": 1,
"usd_value": "2.80"
},
{
"name": "sephara, sky's blade",
"count": 2,
"usd_value": "2.79"
},
{ {
"name": "poppet stitcher", "name": "poppet stitcher",
"count": 1, "count": 1,
"usd_value": "2.77" "usd_value": "2.77"
}, },
{
"name": "ugin, the ineffable",
"count": 1,
"usd_value": "2.75"
},
{ {
"name": "rionya, fire dancer", "name": "rionya, fire dancer",
"count": 1, "count": 1,
@ -385,6 +380,11 @@
"count": 1, "count": 1,
"usd_value": "2.39" "usd_value": "2.39"
}, },
{
"name": "sephara, sky's blade",
"count": 2,
"usd_value": "2.33"
},
{ {
"name": "court of cunning", "name": "court of cunning",
"count": 1, "count": 1,
@ -446,19 +446,19 @@
"usd_value": "12.36" "usd_value": "12.36"
}, },
{ {
"name": "kindred discovery", "name": "dryad of the ilysian grove",
"count": 1, "count": 3,
"usd_value": "11.86" "usd_value": "12.13"
}, },
{ {
"name": "vault of champions", "name": "vault of champions",
"count": 1, "count": 1,
"usd_value": "11.74" "usd_value": "11.93"
}, },
{ {
"name": "dryad of the ilysian grove", "name": "kindred discovery",
"count": 3, "count": 1,
"usd_value": "11.26" "usd_value": "11.86"
}, },
{ {
"name": "korvold, fae-cursed king", "name": "korvold, fae-cursed king",
@ -585,11 +585,6 @@
"count": 1, "count": 1,
"usd_value": "1.23" "usd_value": "1.23"
}, },
{
"name": "extinguish all hope",
"count": 1,
"usd_value": "1.22"
},
{ {
"name": "storm the festival", "name": "storm the festival",
"count": 1, "count": 1,
@ -605,6 +600,11 @@
"count": 1, "count": 1,
"usd_value": "1.16" "usd_value": "1.16"
}, },
{
"name": "extinguish all hope",
"count": 1,
"usd_value": "1.15"
},
{ {
"name": "notion thief", "name": "notion thief",
"count": 1, "count": 1,
@ -713,7 +713,7 @@
{ {
"name": "drakuseth, maw of flames", "name": "drakuseth, maw of flames",
"count": 2, "count": 2,
"usd_value": "0.74" "usd_value": "0.75"
}, },
{ {
"name": "verix bladewing", "name": "verix bladewing",
@ -795,11 +795,6 @@
"count": 1, "count": 1,
"usd_value": "0.65" "usd_value": "0.65"
}, },
{
"name": "solemn simulacrum",
"count": 1,
"usd_value": "0.64"
},
{ {
"name": "izoni,thousand-eyed", "name": "izoni,thousand-eyed",
"count": 1, "count": 1,
@ -835,6 +830,11 @@
"count": 1, "count": 1,
"usd_value": "0.60" "usd_value": "0.60"
}, },
{
"name": "solemn simulacrum",
"count": 1,
"usd_value": "0.59"
},
{ {
"name": "goro-goro, disciple of ryusei", "name": "goro-goro, disciple of ryusei",
"count": 1, "count": 1,
@ -906,15 +906,20 @@
"usd_value": "0.51" "usd_value": "0.51"
}, },
{ {
"name": "cultivate", "name": "notorious throng",
"count": 1, "count": 1,
"usd_value": "0.50" "usd_value": "0.50"
}, },
{ {
"name": "notorious throng", "name": "talrand, sky summoner",
"count": 1, "count": 1,
"usd_value": "0.50" "usd_value": "0.50"
}, },
{
"name": "cultivate",
"count": 1,
"usd_value": "0.49"
},
{ {
"name": "mirror-mad phantasm", "name": "mirror-mad phantasm",
"count": 2, "count": 2,
@ -955,11 +960,6 @@
"count": 1, "count": 1,
"usd_value": "0.48" "usd_value": "0.48"
}, },
{
"name": "talrand, sky summoner",
"count": 1,
"usd_value": "0.47"
},
{ {
"name": "boros reckoner", "name": "boros reckoner",
"count": 1, "count": 1,
@ -985,6 +985,11 @@
"count": 1, "count": 1,
"usd_value": "0.46" "usd_value": "0.46"
}, },
{
"name": "metalwork colossus",
"count": 1,
"usd_value": "0.44"
},
{ {
"name": "inkwell leviathan", "name": "inkwell leviathan",
"count": 1, "count": 1,
@ -1000,11 +1005,6 @@
"count": 3, "count": 3,
"usd_value": "0.43" "usd_value": "0.43"
}, },
{
"name": "metalwork colossus",
"count": 1,
"usd_value": "0.42"
},
{ {
"name": "abundance", "name": "abundance",
"count": 1, "count": 1,
@ -1160,6 +1160,11 @@
"count": 1, "count": 1,
"usd_value": "0.32" "usd_value": "0.32"
}, },
{
"name": "sidisi, brood tyrant",
"count": 1,
"usd_value": "0.32"
},
{ {
"name": "archon of coronation", "name": "archon of coronation",
"count": 1, "count": 1,
@ -1270,11 +1275,6 @@
"count": 1, "count": 1,
"usd_value": "0.28" "usd_value": "0.28"
}, },
{
"name": "sidisi, brood tyrant",
"count": 1,
"usd_value": "0.28"
},
{ {
"name": "daxos's torment", "name": "daxos's torment",
"count": 1, "count": 1,
@ -1300,6 +1300,11 @@
"count": 1, "count": 1,
"usd_value": "0.28" "usd_value": "0.28"
}, },
{
"name": "melek izzet paragon",
"count": 1,
"usd_value": "0.28"
},
{ {
"name": "ravenloft adventurer", "name": "ravenloft adventurer",
"count": 1, "count": 1,
@ -1325,11 +1330,6 @@
"count": 1, "count": 1,
"usd_value": "0.27" "usd_value": "0.27"
}, },
{
"name": "melek izzet paragon",
"count": 1,
"usd_value": "0.27"
},
{ {
"name": "deputy of detention", "name": "deputy of detention",
"count": 1, "count": 1,
@ -1415,6 +1415,16 @@
"count": 1, "count": 1,
"usd_value": "0.26" "usd_value": "0.26"
}, },
{
"name": "the mending of dominaria",
"count": 1,
"usd_value": "0.26"
},
{
"name": "sarkhan the masterless",
"count": 2,
"usd_value": "0.26"
},
{ {
"name": "needle spires", "name": "needle spires",
"count": 1, "count": 1,
@ -1445,16 +1455,6 @@
"count": 2, "count": 2,
"usd_value": "0.25" "usd_value": "0.25"
}, },
{
"name": "the mending of dominaria",
"count": 1,
"usd_value": "0.25"
},
{
"name": "sarkhan the masterless",
"count": 2,
"usd_value": "0.25"
},
{ {
"name": "eye of doom", "name": "eye of doom",
"count": 1, "count": 1,
@ -1761,13 +1761,18 @@
"usd_value": "0.20" "usd_value": "0.20"
}, },
{ {
"name": "castle embereth", "name": "cinder glade",
"count": 1, "count": 2,
"usd_value": "0.19" "usd_value": "0.20"
}, },
{ {
"name": "exotic orchard", "name": "temple of epiphany",
"count": 2, "count": 2,
"usd_value": "0.20"
},
{
"name": "castle embereth",
"count": 1,
"usd_value": "0.19" "usd_value": "0.19"
}, },
{ {
@ -1851,13 +1856,13 @@
"usd_value": "0.19" "usd_value": "0.19"
}, },
{ {
"name": "spinerock knoll", "name": "exotic orchard",
"count": 1, "count": 2,
"usd_value": "0.18" "usd_value": "0.18"
}, },
{ {
"name": "cinder glade", "name": "spinerock knoll",
"count": 2, "count": 1,
"usd_value": "0.18" "usd_value": "0.18"
}, },
{ {
@ -1935,11 +1940,6 @@
"count": 1, "count": 1,
"usd_value": "0.17" "usd_value": "0.17"
}, },
{
"name": "temple of epiphany",
"count": 2,
"usd_value": "0.17"
},
{ {
"name": "gale, waterdeep prodigy", "name": "gale, waterdeep prodigy",
"count": 1, "count": 1,
@ -2075,6 +2075,11 @@
"count": 1, "count": 1,
"usd_value": "0.16" "usd_value": "0.16"
}, },
{
"name": "teshar, ancestor's apostle",
"count": 1,
"usd_value": "0.16"
},
{ {
"name": "sakashima's protege", "name": "sakashima's protege",
"count": 1, "count": 1,
@ -2148,7 +2153,7 @@
{ {
"name": "temple of triumph", "name": "temple of triumph",
"count": 1, "count": 1,
"usd_value": "0.14" "usd_value": "0.15"
}, },
{ {
"name": "despoiler of souls", "name": "despoiler of souls",
@ -2160,11 +2165,6 @@
"count": 1, "count": 1,
"usd_value": "0.14" "usd_value": "0.14"
}, },
{
"name": "teshar, ancestor's apostle",
"count": 1,
"usd_value": "0.14"
},
{ {
"name": "silver-fur, master", "name": "silver-fur, master",
"count": 1, "count": 1,
@ -2410,6 +2410,11 @@
"count": 1, "count": 1,
"usd_value": "0.12" "usd_value": "0.12"
}, },
{
"name": "anax, hardened in the forge",
"count": 1,
"usd_value": "0.12"
},
{ {
"name": "desolate lighthouse", "name": "desolate lighthouse",
"count": 1, "count": 1,
@ -2485,11 +2490,6 @@
"count": 2, "count": 2,
"usd_value": "0.11" "usd_value": "0.11"
}, },
{
"name": "anax, hardened in the forge",
"count": 1,
"usd_value": "0.11"
},
{ {
"name": "zevlor, elturel exile", "name": "zevlor, elturel exile",
"count": 2, "count": 2,

View file

@ -7,6 +7,7 @@ use std::sync::Arc;
pub async fn run_metrics_server(addr: SocketAddr, registry: Arc<Registry>) { pub async fn run_metrics_server(addr: SocketAddr, registry: Arc<Registry>) {
let app = Router::new() let app = Router::new()
.route("/", get(root)) .route("/", get(root))
.route("/health", get(|| async { "OK" }))
.route("/metrics", get(move || { .route("/metrics", get(move || {
let registry = Arc::clone(&registry); let registry = Arc::clone(&registry);
async move { async move {
@ -31,10 +32,35 @@ async fn root() -> http::Response<hyper::Body> {
<html> <html>
<head> <head>
<title>Library</title> <title>Library</title>
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
</head> </head>
<body> <body>
<h1 >Welcome to the SK Collectors Companion</h1> <h1 >Welcome to the SK Collectors Companion</h1>
<p id="data">Click the button below to get the metrics</p>
<br />
<button id="submit" hx-get="/metrics" hx-target='#data' hx-swap="innerHTML">Get Data</button>
</body> </body>
<style>
body {
background-color: #3d3d3d;
}
h1 {
color: white;
}
#data {
color: white;
}
#submit {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
</html> </html>
"#; "#;

54
test.json Normal file
View file

@ -0,0 +1,54 @@
{
"cards": [
{
"name": "noble hierarch",
"count": 2,
"usd_value": "9.93"
},
{
"name": "wound reflection",
"count": 1,
"usd_value": "9.42"
},
{
"name": "ancient gold dragon",
"count": 1,
"usd_value": "8.82"
},
{
"name": "farewell",
"count": 1,
"usd_value": "8.73"
},
{
"name": "shark typhoon",
"count": 1,
"usd_value": "8.72"
},
{
"name": "conjurer's closet",
"count": 1,
"usd_value": "8.49"
},
{
"name": "sneak attack",
"count": 1,
"usd_value": "8.14"
},
{
"name": "serpent of yawning depths",
"count": 1,
"usd_value": "7.92"
},
{
"name": "legion loyalist",
"count": 1,
"usd_value": "7.76"
},
{
"name": "wooded bastion",
"count": 1,
"usd_value": "7.67"
}
]
}