Skip to content

Commit c3b2901

Browse files
committed
Update stats page with new API format
1 parent ae3a054 commit c3b2901

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/game/backend.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ export async function postRun(game, playerName) {
5959
}
6060

6161
/**
62-
* @returns {Promise<Run[]>} list of game runs
62+
* @returns {Promise<{runs: Run[], total: number}>} list of game runs
6363
*/
6464
export async function getRuns() {
6565
const res = await fetch(apiUrl)
66-
const {runs} = await res.json()
67-
return runs
66+
return await res.json()
6867
}
6968

7069
/**

src/ui/pages/stats.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Layout from '../layouts/Layout.astro'
33
import {getRuns} from '../../game/backend.js'
44
import '../styles/typography.css'
55
6-
const runs = (await getRuns()).reverse()
6+
let {runs, total} = (await getRuns())
77
---
88

99
<Layout title="Statistics & Highscores">
@@ -18,7 +18,7 @@ const runs = (await getRuns()).reverse()
1818

1919
<div class="Box Box--text Box--full">
2020
<p>
21-
A chronological list of Slay the Web runs.<br />
21+
A chronological list of <strong>{total}</strong> Slay the Web runs. Although we only show 200 latest here because I did not implement pagination and else the server timeouts..<br />
2222
There is quite a bit of statistics that could be gathered from the runs, and isn't yet shown here. <a
2323
href="https://matrix.to/#/#slaytheweb:matrix.org"
2424
rel="nofollow">Chat on #slaytheweb:matrix.org</a>

0 commit comments

Comments
 (0)