From e3164246e1733c717072b804566a485458769314 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Mon, 24 Oct 2022 07:19:52 +0200 Subject: [PATCH] create simple stats page --- .../index.svelte} | 9 +- .../src/routes/bots/[bot_name]/stats.svelte | 169 ++++++++++++++++++ 2 files changed, 175 insertions(+), 3 deletions(-) rename web/pw-server/src/routes/bots/{[bot_name].svelte => [bot_name]/index.svelte} (93%) create mode 100644 web/pw-server/src/routes/bots/[bot_name]/stats.svelte diff --git a/web/pw-server/src/routes/bots/[bot_name].svelte b/web/pw-server/src/routes/bots/[bot_name]/index.svelte similarity index 93% rename from web/pw-server/src/routes/bots/[bot_name].svelte rename to web/pw-server/src/routes/bots/[bot_name]/index.svelte index 58e89ad..6e93834 100644 --- a/web/pw-server/src/routes/bots/[bot_name].svelte +++ b/web/pw-server/src/routes/bots/[bot_name]/index.svelte @@ -5,8 +5,10 @@ const apiClient = new ApiClient(fetch); try { - const [botData, matchesPage] = await Promise.all([ - apiClient.get(`/api/bots/${params["bot_name"]}`), + const bot_name = params["bot_name"]; + const [botData, botStats, matchesPage] = await Promise.all([ + apiClient.get(`/api/bots/${bot_name}`), + apiClient.get(`/api/bots/${bot_name}/stats`), apiClient.get("/api/matches", { bot: params["bot_name"], count: "20" }), ]); @@ -19,6 +21,7 @@ bot, owner, versions, + botStats, matches: matchesPage["matches"], }, }; @@ -41,7 +44,7 @@ export let owner: object; export let versions: object[]; export let matches: object[]; - + export let botStats: object; // function last_updated() { // versions.sort() // } diff --git a/web/pw-server/src/routes/bots/[bot_name]/stats.svelte b/web/pw-server/src/routes/bots/[bot_name]/stats.svelte new file mode 100644 index 0000000..6b5a2e1 --- /dev/null +++ b/web/pw-server/src/routes/bots/[bot_name]/stats.svelte @@ -0,0 +1,169 @@ + + + + +
+
+

{bot["name"]}

+ {#if owner} + + {owner["username"]} + + {/if} +
+

Stats

+ + + + + + + + + + {#each leaderboard as entry, index} + + + + + + {#if mergedStats[entry["bot"]["name"]]} + + + {:else} + {/if} + + {/each} +
RankRatingBotAuthorWinrateMatches
{index + 1} + {entry["rating"].toFixed(0)} + + {entry["bot"]["name"]} + + {#if entry["author"]} + + {entry["author"]["username"]} + {/if} + + {winRate(mergedStats[entry["bot"]["name"]]).toFixed(2)} + + view matches + + no matches yet
+
+ +