diff --git a/app/webapp/app/Controllers/Http/GameController.js b/app/webapp/app/Controllers/Http/GameController.js index de6d164..54fcef7 100644 --- a/app/webapp/app/Controllers/Http/GameController.js +++ b/app/webapp/app/Controllers/Http/GameController.js @@ -9,15 +9,25 @@ class GameController { const pageTitle = `Latest Games`; - const gamesQry = await Database.raw(` - SELECT distinct game_id,map,gametype, datestamp - FROM games - WHERE (stats->>'score' IS NOT NULL) AND (game_id <> 0) - ORDER BY game_id desc - LIMIT 2000; - `); + // const gamesQry = await Database.raw(` + // SELECT distinct game_id,map,gametype, datestamp + // FROM games + // WHERE (stats->>'score' IS NOT NULL) AND (game_id <> 0) + // ORDER BY game_id desc + // LIMIT 2000; + // `); + const gamesQry = await Database.raw(` + WITH gamelist AS ( + SELECT DISTINCT p.game_id, p.map, p.gametype, p.datestamp, count(*) OVER (PARTITION BY game_id) as count from games p + ) + SELECT * from gamelist + WHERE (count > 1) AND (game_id <> 0) + ORDER BY game_id desc + LIMIT 2000 + `); + // filter out duplicate game_ids (https://dev.to/marinamosti/removing-duplicates-in-an-array-of-objects-in-js-with-sets-3fep) const games = gamesQry.rows.reduce((game, current) => { diff --git a/app/webapp/app/Controllers/Http/PlayerController.js b/app/webapp/app/Controllers/Http/PlayerController.js index 30caa9c..d2521b1 100644 --- a/app/webapp/app/Controllers/Http/PlayerController.js +++ b/app/webapp/app/Controllers/Http/PlayerController.js @@ -40,6 +40,7 @@ class PlayerController { 'gametype', 'stats') .where({ player_guid: request.params.player_guid }) + .orderBy('game_id', 'desc') .limit(50) diff --git a/app/webapp/resources/views/app.edge b/app/webapp/resources/views/app.edge index 615b428..f1c0df1 100644 --- a/app/webapp/resources/views/app.edge +++ b/app/webapp/resources/views/app.edge @@ -14,12 +14,41 @@ @endif + + + + {{{ startTag }}} + {{-- {{ edgeVar }} --}} @if(node_env().env === "production" || node_env().hmr === "false") {{ script(versionjs('app')) }} @else {{ script('http://localhost:8081/dist/js/app.js') }} @endif + + + + +