From e3164246e1733c717072b804566a485458769314 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Mon, 24 Oct 2022 07:19:52 +0200 Subject: create simple stats page --- web/pw-server/src/routes/bots/[bot_name].svelte | 173 -------------------- .../src/routes/bots/[bot_name]/index.svelte | 176 +++++++++++++++++++++ .../src/routes/bots/[bot_name]/stats.svelte | 169 ++++++++++++++++++++ 3 files changed, 345 insertions(+), 173 deletions(-) delete mode 100644 web/pw-server/src/routes/bots/[bot_name].svelte create mode 100644 web/pw-server/src/routes/bots/[bot_name]/index.svelte 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].svelte deleted file mode 100644 index 58e89ad..0000000 --- a/web/pw-server/src/routes/bots/[bot_name].svelte +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - -
-
-

{bot["name"]}

- {#if owner} - - {owner["username"]} - - {/if} -
- - {#if $currentUser && $currentUser["user_id"] === bot["owner_id"]} -
- - Publish a new version by pushing a docker container to - registry.planetwars.dev/{bot["name"]}:latest, or using the web editor. -
- -
-

Versions

-
    - {#each versions.slice(0, 10) as version} -
  • - {dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")} - {#if version["container_digest"]} - {version["container_digest"]} - {:else} - view code - {/if} -
  • - {/each} -
- {#if versions.length == 0} - This bot does not have any versions yet. - {/if} -
- {/if} - -
-

Recent matches

- - {#if matches.length > 0} -
- All matches -
- {/if} -
-
- - diff --git a/web/pw-server/src/routes/bots/[bot_name]/index.svelte b/web/pw-server/src/routes/bots/[bot_name]/index.svelte new file mode 100644 index 0000000..6e93834 --- /dev/null +++ b/web/pw-server/src/routes/bots/[bot_name]/index.svelte @@ -0,0 +1,176 @@ + + + + + + +
+
+

{bot["name"]}

+ {#if owner} + + {owner["username"]} + + {/if} +
+ + {#if $currentUser && $currentUser["user_id"] === bot["owner_id"]} +
+ + Publish a new version by pushing a docker container to + registry.planetwars.dev/{bot["name"]}:latest, or using the web editor. +
+ +
+

Versions

+
    + {#each versions.slice(0, 10) as version} +
  • + {dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")} + {#if version["container_digest"]} + {version["container_digest"]} + {:else} + view code + {/if} +
  • + {/each} +
+ {#if versions.length == 0} + This bot does not have any versions yet. + {/if} +
+ {/if} + +
+

Recent matches

+ + {#if matches.length > 0} +
+ All matches +
+ {/if} +
+
+ + 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
+
+ + -- cgit v1.2.3