Add IRS% to Team Stats and individual leaderboards. Also updated tie breakers for individual leaderboards based on PAs/IP/XCh respectively

This commit is contained in:
Peter 2024-11-01 13:48:30 -05:00
parent 61c14786dc
commit 3b86910465
3 changed files with 43 additions and 8 deletions

View File

@ -27,6 +27,7 @@
<th>WP</th> <th>WP</th>
<th>IR</th> <th>IR</th>
<th>IRS</th> <th>IRS</th>
<th>IRS%</th>
<th>WHIP</th> <th>WHIP</th>
<th>H/9</th> <th>H/9</th>
<th>HR/9</th> <th>HR/9</th>
@ -66,6 +67,7 @@
<td>{{ stat.wp }}</td> <td>{{ stat.wp }}</td>
<td>{{ stat.ir }}</td> <td>{{ stat.ir }}</td>
<td>{{ stat.ir_sc }}</td> <td>{{ stat.ir_sc }}</td>
<td>{{ formatIRSPercentage(stat) }}</td>
<td>{{ stat.whip.toFixed(2) }}</td> <td>{{ stat.whip.toFixed(2) }}</td>
<td>{{ hitsPer9(stat) }}</td> <td>{{ hitsPer9(stat) }}</td>
<td>{{ hrsPer9(stat) }}</td> <td>{{ hrsPer9(stat) }}</td>
@ -98,6 +100,7 @@
<th>{{ totalPitchingStat.wp }}</th> <th>{{ totalPitchingStat.wp }}</th>
<th>{{ totalPitchingStat.ir }}</th> <th>{{ totalPitchingStat.ir }}</th>
<th>{{ totalPitchingStat.ir_sc }}</th> <th>{{ totalPitchingStat.ir_sc }}</th>
<td>{{ formatIRSPercentage(totalPitchingStat) }}</td>
<th>{{ totalPitchingStat.whip.toFixed(2) }}</th> <th>{{ totalPitchingStat.whip.toFixed(2) }}</th>
<th>{{ hitsPer9(totalPitchingStat) }}</th> <th>{{ hitsPer9(totalPitchingStat) }}</th>
<th>{{ hrsPer9(totalPitchingStat) }}</th> <th>{{ hrsPer9(totalPitchingStat) }}</th>
@ -162,6 +165,11 @@ export default {
}, },
hrsPer9(stat: PitchingStat): string { hrsPer9(stat: PitchingStat): string {
return hrsPer9(stat) return hrsPer9(stat)
},
formatIRSPercentage(stat: PitchingStat): string {
if (stat.ir === 0) return '-'
return `${(stat.ir_sc_pct * 100).toFixed(1)}%`
} }
} }
} }

View File

@ -67,7 +67,7 @@ import { outsToInnings } from '@/services/utilities'
import type { PropType } from 'vue' import type { PropType } from 'vue'
export default { export default {
name: "PlayerPitchingSummaryTable", name: 'PlayerPitchingSummaryTable',
props: { props: {
currentSeasonPitching: { type: Object as PropType<PitchingStat>, required: false }, currentSeasonPitching: { type: Object as PropType<PitchingStat>, required: false },
currentPostSeasonPitching: { type: Object as PropType<PitchingStat>, required: false }, currentPostSeasonPitching: { type: Object as PropType<PitchingStat>, required: false },

View File

@ -226,7 +226,8 @@ export default {
{ title: 'Wild Pitches', columnName: 'WP', statPropertyName: 'wp' }, { title: 'Wild Pitches', columnName: 'WP', statPropertyName: 'wp' },
{ title: 'Inherited Runners', columnName: 'IR', statPropertyName: 'ir' }, { title: 'Inherited Runners', columnName: 'IR', statPropertyName: 'ir' },
{ title: 'Inherited Runners Scored', columnName: 'IRS', statPropertyName: 'ir_sc' } { title: 'Inherited Runners Scored', columnName: 'IRS', statPropertyName: 'ir_sc' },
{ title: 'Inherited Runners Scored %', columnName: 'IRS%', statPropertyName: 'ir_sc_pct' }
] ]
}, },
fieldingLeaderboardTableData(): LeaderboardTableData<FlatFieldingStat>[] { fieldingLeaderboardTableData(): LeaderboardTableData<FlatFieldingStat>[] {
@ -284,11 +285,16 @@ export default {
const statBase: BattingStat[] = paExemptStat.includes(stat) ? this.allPlayersBattingStats.concat([]) : this.qualifyingBattingStats.concat([]) const statBase: BattingStat[] = paExemptStat.includes(stat) ? this.allPlayersBattingStats.concat([]) : this.qualifyingBattingStats.concat([])
const sortMultiplier = this.invertSort ? -1 : 1 const sortMultiplier = this.invertSort ? -1 : 1
return statBase.sort((a, b) => sortMultiplier * ((b[stat] as number) - (a[stat] as number))).slice(0, 10) return statBase
.sort((a, b) =>
sortMultiplier * ((b[stat] as number) - (a[stat] as number)) !== 0
? sortMultiplier * ((b[stat] as number) - (a[stat] as number))
: b.pa - a.pa)
.slice(0, 10)
}, },
getTop10PitchingStatByCategory(stat: keyof PitchingStat): PitchingStat[] { getTop10PitchingStatByCategory(stat: keyof PitchingStat): PitchingStat[] {
// qualifying IP exempt stats // qualifying IP exempt stats
const ipExemptStats: (keyof PitchingStat)[] = ['win', 'loss', 'save', 'bsave', 'hold', 'so', 'bb', 'hbp', 'hits', 'hr', 'run', 'e_run', 'balk', 'wp', 'ir', 'ir_sc'] const ipExemptStats: (keyof PitchingStat)[] = ['win', 'loss', 'save', 'bsave', 'hold', 'so', 'bb', 'hbp', 'hits', 'hr', 'run', 'e_run', 'balk', 'wp', 'ir', 'ir_sc', 'ir_sc_pct']
// concat an empty array so that the existing array is not sorted as a side effect // concat an empty array so that the existing array is not sorted as a side effect
const statBase: PitchingStat[] = ipExemptStats.includes(stat) ? this.allPlayersPitchingStats.concat([]) : this.qualifyingPitchingStats.concat([]) const statBase: PitchingStat[] = ipExemptStats.includes(stat) ? this.allPlayersPitchingStats.concat([]) : this.qualifyingPitchingStats.concat([])
@ -301,10 +307,26 @@ export default {
: s.gs === 0 : s.gs === 0
) )
const reverseSortStats = ['era', 'whip', 'bbPer9'] const reverseSortStats = ['era', 'whip', 'bbPer9', 'ir_sc_pct']
const sortMultiplier = (reverseSortStats.includes(stat) ? -1 : 1) * (this.invertSort ? -1 : 1) const sortMultiplier = (reverseSortStats.includes(stat) ? -1 : 1) * (this.invertSort ? -1 : 1)
return filteredStatBase.sort((a, b) => sortMultiplier * ((b[stat] as number) - (a[stat] as number))).slice(0, 10) // janky workaround for irs% without weird entries
if (stat === 'ir_sc_pct') {
return filteredStatBase
.filter(s => s.ir > 0)
.sort((a, b) =>
sortMultiplier * ((b[stat] as number) - (a[stat] as number)) !== 0
? sortMultiplier * ((b[stat] as number) - (a[stat] as number))
: b.ip - a.ip)
.slice(0, 10)
}
return filteredStatBase
.sort((a, b) =>
sortMultiplier * ((b[stat] as number) - (a[stat] as number)) !== 0
? sortMultiplier * ((b[stat] as number) - (a[stat] as number))
: b.ip - a.ip)
.slice(0, 10)
}, },
getTop10FieldingStatByCategory(stat: keyof FlatFieldingStat): FlatFieldingStat[] { getTop10FieldingStatByCategory(stat: keyof FlatFieldingStat): FlatFieldingStat[] {
// High: 2B/SS - 2 XCh/wk // High: 2B/SS - 2 XCh/wk
@ -328,9 +350,14 @@ export default {
const xCheckCountProperty = `xCheckCount${position[1]}` as keyof FlatFieldingStat const xCheckCountProperty = `xCheckCount${position[1]}` as keyof FlatFieldingStat
const sortMultiplier = this.invertSort ? -1 : 1 const sortMultiplier = this.invertSort ? -1 : 1
return this.allPlayersFieldingStats.concat([]) return this.allPlayersFieldingStats
.concat([])
.filter(stat => (stat[xCheckCountProperty] as number) >= Math.floor(xCheckCountPerWeek * this.weekNumberForCalcs)) .filter(stat => (stat[xCheckCountProperty] as number) >= Math.floor(xCheckCountPerWeek * this.weekNumberForCalcs))
.sort((a, b) => sortMultiplier * ((b[stat] as number) - (a[stat] as number))).slice(0, 10) .sort((a, b) =>
sortMultiplier * ((b[stat] as number) - (a[stat] as number)) !== 0
? sortMultiplier * ((b[stat] as number) - (a[stat] as number))
: b.xCheckCount - a.xCheckCount)
.slice(0, 10)
} }
// non-wF% stats currently won't have any qualifying minimum // non-wF% stats currently won't have any qualifying minimum