Add IRS% to team page

This commit is contained in:
Peter 2024-11-01 13:10:59 -05:00
parent 0e273f4d2c
commit 78e3dae91c
2 changed files with 17 additions and 0 deletions

View File

@ -28,6 +28,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>
@ -67,6 +68,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>
@ -99,6 +101,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>
<th>{{ formatIRSPercentage(totalPitchingStat) }}</th>
<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>
@ -163,6 +166,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

@ -22,6 +22,7 @@ export interface PitchingStat {
bsave: number bsave: number
ir: number ir: number
ir_sc: number ir_sc: number
ir_sc_pct: number
ab: number ab: number
run: number run: number
e_run: number e_run: number
@ -273,6 +274,7 @@ export function aggregatePitchingStats(pitchingStats: PitchingStat[]): PitchingS
bsave: 0, bsave: 0,
ir: 0, ir: 0,
ir_sc: 0, ir_sc: 0,
ir_sc_pct: 0,
ab: 0, ab: 0,
run: 0, run: 0,
e_run: 0, e_run: 0,
@ -350,6 +352,7 @@ export function aggregatePitchingStats(pitchingStats: PitchingStat[]): PitchingS
return { return {
...totalStat, ...totalStat,
ir_sc_pct: irsPercentage(totalStat),
era: eraFromOuts(totalStat), era: eraFromOuts(totalStat),
whip: whipFromOuts(totalStat), whip: whipFromOuts(totalStat),
kPer9: kPer9FromOuts(totalStat), kPer9: kPer9FromOuts(totalStat),
@ -397,6 +400,7 @@ function makeModernPitchingStatFromLegacy(legacyStat: LegacyPitchingStat): Pitch
kPer9: kPer9(legacyStat), kPer9: kPer9(legacyStat),
bbPer9: bbPer9(legacyStat), bbPer9: bbPer9(legacyStat),
kPerBB: kPerBB(legacyStat), kPerBB: kPerBB(legacyStat),
ir_sc_pct: irsPercentage({ ir: legacyStat.ir, ir_sc: legacyStat.irs }),
// no easy way to get below values from legacy stats afaik // no easy way to get below values from legacy stats afaik
tbf: 0, tbf: 0,
@ -438,6 +442,7 @@ function normalizePitchingStat(rawStat: PitchingStatRaw): PitchingStat {
bsave: rawStat.bsave, bsave: rawStat.bsave,
ir: rawStat.ir, ir: rawStat.ir,
ir_sc: rawStat.ir_sc, ir_sc: rawStat.ir_sc,
ir_sc_pct: irsPercentage(rawStat),
ab: rawStat.ab, ab: rawStat.ab,
run: rawStat.run, run: rawStat.run,
e_run: rawStat.e_run, e_run: rawStat.e_run,
@ -528,3 +533,7 @@ function kPerBB(stat: { so: number, bb: number }): number {
return stat.so / stat.bb return stat.so / stat.bb
} }
function irsPercentage(stat: { ir: number, ir_sc: number }): number {
return stat.ir === 0 ? 0 : stat.ir_sc / stat.ir
}