mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-07-12 23:04:34 +00:00
Adjust limits for performance
This commit is contained in:
parent
56878c47d6
commit
2cf1a508d5
5 changed files with 18 additions and 18 deletions
|
|
@ -6,20 +6,21 @@ class GameController {
|
||||||
|
|
||||||
// /games
|
// /games
|
||||||
async index({ inertia }) {
|
async index({ inertia }) {
|
||||||
const pageTitle = "Last 1000 Games";
|
|
||||||
|
|
||||||
const gamesQry = await Database.table('games')
|
const pageTitle = `Latest Games`;
|
||||||
.distinct('game_id',
|
|
||||||
'map',
|
const gamesQry = await Database.raw(`
|
||||||
'gametype',
|
SELECT distinct game_id,map,gametype, datestamp
|
||||||
'stats',
|
FROM games
|
||||||
'datestamp')
|
WHERE (stats->>'score' IS NOT NULL) AND (game_id <> 0)
|
||||||
.where('game_id', '<>', 0)
|
ORDER BY game_id desc
|
||||||
.orderBy('game_id', 'desc')
|
LIMIT 2000;
|
||||||
.limit(1000)
|
`);
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
const x = game.find(item => item.game_id === current.game_id);
|
||||||
if (!x) {
|
if (!x) {
|
||||||
return game.concat([current]);
|
return game.concat([current]);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class PlayerController {
|
||||||
'updated_at')
|
'updated_at')
|
||||||
.groupBy('player_guid')
|
.groupBy('player_guid')
|
||||||
.orderBy('player_name', 'asc')
|
.orderBy('player_name', 'asc')
|
||||||
.limit(2500)
|
.limit(1000)
|
||||||
|
|
||||||
return inertia.render('Players/Main', { pageTitle, players }, { edgeVar: 'server-variable' })
|
return inertia.render('Players/Main', { pageTitle, players }, { edgeVar: 'server-variable' })
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +32,7 @@ class PlayerController {
|
||||||
'total_games_lakrabbitgame',
|
'total_games_lakrabbitgame',
|
||||||
'total_games_sctfgame')
|
'total_games_sctfgame')
|
||||||
.where({ player_guid: request.params.player_guid })
|
.where({ player_guid: request.params.player_guid })
|
||||||
|
.limit(50)
|
||||||
|
|
||||||
|
|
||||||
const playerStatData = await Database.from('games')
|
const playerStatData = await Database.from('games')
|
||||||
|
|
@ -39,6 +40,7 @@ class PlayerController {
|
||||||
'gametype',
|
'gametype',
|
||||||
'stats')
|
'stats')
|
||||||
.where({ player_guid: request.params.player_guid })
|
.where({ player_guid: request.params.player_guid })
|
||||||
|
.limit(50)
|
||||||
|
|
||||||
|
|
||||||
// Dynamically generate and sum the stats object
|
// Dynamically generate and sum the stats object
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export class TwoLevelPieChart extends PureComponent {
|
||||||
|
|
||||||
const PlayerRow = (player, index) => {
|
const PlayerRow = (player, index) => {
|
||||||
// dont show scoreless players
|
// 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}>
|
return <div className="flex flex-col rounded-lg shadow-lg overflow-hidden" key={index}>
|
||||||
<div className="bg-white shadow overflow-hidden sm:rounded-lg">
|
<div className="bg-white shadow overflow-hidden sm:rounded-lg">
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ import Layout from '@/Shared/Layout'
|
||||||
|
|
||||||
const GameRow = (game, index) => {
|
const GameRow = (game, index) => {
|
||||||
|
|
||||||
// TODO: move this into controller for faster render
|
|
||||||
if (Number(game.stats.score) === 0){return}
|
|
||||||
|
|
||||||
return <li key={index}>
|
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">
|
<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">
|
<div className="flex items-center px-4 py-4 sm:px-6">
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export default function Player(props) {
|
||||||
{ props.playerData.stats.map((player, index) => GameCard(player, index)) }
|
{ props.playerData.stats.map((player, index) => GameCard(player, index)) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/*
|
{/*
|
||||||
|
|
||||||
<div className="bg-white shadow overflow-hidden sm:rounded-md">
|
<div className="bg-white shadow overflow-hidden sm:rounded-md">
|
||||||
<div className="py-10 px-10"><code> {JSON.stringify(props.playerData.stats)}</code></div>
|
<div className="py-10 px-10"><code> {JSON.stringify(props.playerData.stats)}</code></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue