diff --git a/libs/database/wrapper.js b/libs/database/wrapper.js index 06c2cce..002edba 100644 --- a/libs/database/wrapper.js +++ b/libs/database/wrapper.js @@ -319,6 +319,15 @@ export function finishedMaps(player) { return unfinished } +export function graphMap(map) { + const finishes = sqlite.prepare(`SELECT * FROM graphRecordCache WHERE map = ? ORDER BY date`) + + let array = [] + for (const record of finishes.iterate(map)) + array.push({ t: record.date, y: record.time, player: record.player}) + + return array +} export default { playerExists, finishedMaps, @@ -326,6 +335,7 @@ export default { player, map, + graphMap, mapCategory, allMaps, mapExists, diff --git a/routes/routes.js b/routes/routes.js index 4bcd1e7..d171952 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -23,9 +23,11 @@ routes.get( '/maps/:map', (req, res) => { const map = wrapper.map(req.params.map) + const graphMap = wrapper.graphMap(req.params.map) const raceLeaderboard = wrapper.leaderboardRace(req.params.map, 1, 10) const teamLeaderboard = wrapper.leaderboardTeamrace(req.params.map, 1, 10) - tx(req, res)('pages/mapSingle.njk', { map, raceLeaderboard, teamLeaderboard }, { currentSection: "maps" }) + + tx(req, res)('pages/mapSingle.njk', { map, graphMap, raceLeaderboard, teamLeaderboard }, { currentSection: "maps" }) } ) diff --git a/views/pages/mapSingle.njk b/views/pages/mapSingle.njk index e585751..e3ede41 100644 --- a/views/pages/mapSingle.njk +++ b/views/pages/mapSingle.njk @@ -3,11 +3,13 @@ {% set map = data.map %} {% set raceLeaderboard = data.raceLeaderboard %} {% set teamLeaderboard = data.teamLeaderboard %} - +{% set graphMap = data.graphMap %} {% block head %} DDStats - Maps! + + {% endblock %} {% block body %} @@ -89,7 +91,7 @@ Median time: - {{ map.times.median | round(2)}} + {{ map.times.median | round(2) }} @@ -97,9 +99,91 @@ Average time: - {{ map.times.average | round(2)}} + {{ map.times.average | round(2) }} + +

Records!

+ {% for record in raceLeaderboard %} + + {{ record.rank }} - + {{ (record.time - (record.time % 60)) / 60 }}: + {%- if record.time | round % 60 > 9 %} + {{- record.time | round % 60 }} + {%- else %} + 0{{- record.time | round % 60 }} + {% endif %} + {{ record.player }}
+ {% endfor %} + +

Team records!

+ {% for record in teamLeaderboard %} + + {{ record.teamrank }} - + {{ (record.time - (record.time % 60)) / 60 }}: + {%- if record.time | round % 60 > 9 %} + {{- record.time | round % 60 }} + {%- else %} + 0{{- record.time | round % 60 }} + {% endif %} + {{ record.players.join(", ") }}
+ {% endfor %} + +

Record over time

+
+ +
+ + {% endblock %} \ No newline at end of file