mirror of
https://github.com/ershisan99/www.git
synced 2025-12-18 12:34:17 +00:00
fix opponents tab winrate
This commit is contained in:
@@ -92,14 +92,16 @@ const useColumns = () => {
|
|||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex items-center justify-end font-medium font-mono',
|
'flex items-center justify-end font-medium font-mono',
|
||||||
winRate === 50
|
winRate !== null
|
||||||
|
? winRate === 50
|
||||||
? 'text-zink-800 dark:text-zink-200'
|
? 'text-zink-800 dark:text-zink-200'
|
||||||
: winRate > 50
|
: winRate > 50
|
||||||
? 'text-emerald-500'
|
? 'text-emerald-500'
|
||||||
: 'text-rose-500'
|
: 'text-rose-500'
|
||||||
|
: null
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{Math.round(winRate)}%
|
{winRate !== null ? `${Math.round(winRate)}%` : 'N/A'}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -143,7 +145,7 @@ type Stats = {
|
|||||||
opponentName: string
|
opponentName: string
|
||||||
opponentId: string
|
opponentId: string
|
||||||
totalMMRChange: number
|
totalMMRChange: number
|
||||||
winRate: number
|
winRate: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
function RawOpponentsTable({ games }: { games: SelectGames[] }) {
|
function RawOpponentsTable({ games }: { games: SelectGames[] }) {
|
||||||
@@ -157,7 +159,9 @@ function RawOpponentsTable({ games }: { games: SelectGames[] }) {
|
|||||||
const tableData: Stats[] = useMemo(
|
const tableData: Stats[] = useMemo(
|
||||||
() =>
|
() =>
|
||||||
Object.values(grouped).map((gamesAgainstOpponent) => {
|
Object.values(grouped).map((gamesAgainstOpponent) => {
|
||||||
const totalGames = gamesAgainstOpponent.length
|
const totalGames = gamesAgainstOpponent.filter(
|
||||||
|
(x) => x.result !== 'tie'
|
||||||
|
).length
|
||||||
let wins = 0
|
let wins = 0
|
||||||
let losses = 0
|
let losses = 0
|
||||||
let totalMMRChange = 0
|
let totalMMRChange = 0
|
||||||
@@ -174,7 +178,7 @@ function RawOpponentsTable({ games }: { games: SelectGames[] }) {
|
|||||||
opponentName: gamesAgainstOpponent[0].opponentName,
|
opponentName: gamesAgainstOpponent[0].opponentName,
|
||||||
opponentId: gamesAgainstOpponent[0].opponentId,
|
opponentId: gamesAgainstOpponent[0].opponentId,
|
||||||
totalMMRChange,
|
totalMMRChange,
|
||||||
winRate: (wins / totalGames) * 100,
|
winRate: totalGames ? (wins / totalGames) * 100 : null,
|
||||||
}
|
}
|
||||||
return stats
|
return stats
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user