diff --git a/app/webapp/app/Controllers/Http/GameController.js b/app/webapp/app/Controllers/Http/GameController.js index c22dd2c..de6d164 100644 --- a/app/webapp/app/Controllers/Http/GameController.js +++ b/app/webapp/app/Controllers/Http/GameController.js @@ -6,20 +6,21 @@ class GameController { // /games async index({ inertia }) { - const pageTitle = "Last 1000 Games"; - const gamesQry = await Database.table('games') - .distinct('game_id', - 'map', - 'gametype', - 'stats', - 'datestamp') - .where('game_id', '<>', 0) - .orderBy('game_id', 'desc') - .limit(1000) + 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; + `); + + + // 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) => { - // filter out duplicate game_ids (https://dev.to/marinamosti/removing-duplicates-in-an-array-of-objects-in-js-with-sets-3fep) - const games = gamesQry.reduce((game, current) => { const x = game.find(item => item.game_id === current.game_id); if (!x) { return game.concat([current]); diff --git a/app/webapp/app/Controllers/Http/PlayerController.js b/app/webapp/app/Controllers/Http/PlayerController.js index ef051dd..30caa9c 100644 --- a/app/webapp/app/Controllers/Http/PlayerController.js +++ b/app/webapp/app/Controllers/Http/PlayerController.js @@ -17,7 +17,7 @@ class PlayerController { 'updated_at') .groupBy('player_guid') .orderBy('player_name', 'asc') - .limit(2500) + .limit(1000) return inertia.render('Players/Main', { pageTitle, players }, { edgeVar: 'server-variable' }) } @@ -32,6 +32,7 @@ class PlayerController { 'total_games_lakrabbitgame', 'total_games_sctfgame') .where({ player_guid: request.params.player_guid }) + .limit(50) const playerStatData = await Database.from('games') @@ -39,6 +40,7 @@ class PlayerController { 'gametype', 'stats') .where({ player_guid: request.params.player_guid }) + .limit(50) // Dynamically generate and sum the stats object diff --git a/app/webapp/resources/js/Pages/Games/Game.js b/app/webapp/resources/js/Pages/Games/Game.js index b86808f..7e6818d 100644 --- a/app/webapp/resources/js/Pages/Games/Game.js +++ b/app/webapp/resources/js/Pages/Games/Game.js @@ -86,7 +86,7 @@ export class TwoLevelPieChart extends PureComponent { const PlayerRow = (player, index) => { // dont show scoreless players - if (Number(player.stats.score) <= 0){return} + //if (Number(player.stats.score) <= 0){return} return
diff --git a/app/webapp/resources/js/Pages/Games/Main.js b/app/webapp/resources/js/Pages/Games/Main.js index ddfa4be..a339b09 100644 --- a/app/webapp/resources/js/Pages/Games/Main.js +++ b/app/webapp/resources/js/Pages/Games/Main.js @@ -6,9 +6,6 @@ import Layout from '@/Shared/Layout' const GameRow = (game, index) => { - // TODO: move this into controller for faster render - if (Number(game.stats.score) === 0){return} - return
  • diff --git a/app/webapp/resources/js/Pages/Players/Player.js b/app/webapp/resources/js/Pages/Players/Player.js index 8a39b09..b8d74dc 100644 --- a/app/webapp/resources/js/Pages/Players/Player.js +++ b/app/webapp/resources/js/Pages/Players/Player.js @@ -156,7 +156,7 @@ export default function Player(props) { { props.playerData.stats.map((player, index) => GameCard(player, index)) }
  • -{/* +{/*
    {JSON.stringify(props.playerData.stats)}