mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-01-20 01:34:47 +00:00
Adjust limits for performance
This commit is contained in:
parent
56878c47d6
commit
2cf1a508d5
|
|
@ -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.reduce((game, current) => {
|
||||
const games = gamesQry.rows.reduce((game, current) => {
|
||||
|
||||
const x = game.find(item => item.game_id === current.game_id);
|
||||
if (!x) {
|
||||
return game.concat([current]);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <div className="flex flex-col rounded-lg shadow-lg overflow-hidden" key={index}>
|
||||
<div className="bg-white shadow overflow-hidden sm:rounded-lg">
|
||||
|
|
|
|||
|
|
@ -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 <li key={index}>
|
||||
<InertiaLink href={`/game/${game.game_id}`} className="block hover:bg-gray-50 focus:outline-none focus:bg-gray-50 transition duration-150 ease-in-out">
|
||||
<div className="flex items-center px-4 py-4 sm:px-6">
|
||||
|
|
|
|||
Loading…
Reference in a new issue