diff --git a/app/routers_v3/stratplay.py b/app/routers_v3/stratplay.py index edb465d..8aef151 100644 --- a/app/routers_v3/stratplay.py +++ b/app/routers_v3/stratplay.py @@ -468,7 +468,7 @@ async def get_batting_totals( 'slg': slg, 'ops': obp + slg, 'woba': (.69 * x.sum_bb + .72 * x.sum_hbp + .89 * (x.sum_hit - x.sum_double - x.sum_triple - x.sum_hr) + - 1.27 * x.sum_double + 1.62 * x.sum_triple + 2.1 * x.sum_hr) / (x.sum_pa - x.sum_ibb), + 1.27 * x.sum_double + 1.62 * x.sum_triple + 2.1 * x.sum_hr) / max(x.sum_pa - x.sum_ibb, 1), 'game': this_game, 'lob_all': x.count_lo1 + x.count_lo2 + x.count_lo3, 'lob_all_rate': lob_all_rate, @@ -476,10 +476,6 @@ async def get_batting_totals( 'rbi%': rbi_rate }) - # Get Running Stats - - # Get Fielding Stats - db.close() return return_stats @@ -506,7 +502,7 @@ async def get_pitching_totals( StratPlay .select(StratPlay.pitcher, StratPlay.pitcher_team, StratPlay.game, fn.SUM(StratPlay.pa).alias('sum_pa'), fn.SUM(StratPlay.ab).alias('sum_ab'), fn.SUM(StratPlay.run).alias('sum_run'), - fn.SUM(StratPlay.hit).alias('sum_hit'), + fn.SUM(StratPlay.hit).alias('sum_hit'), fn.SUM(StratPlay.rbi).alias('sum_rbi'), fn.SUM(StratPlay.double).alias('sum_double'), fn.SUM(StratPlay.triple).alias('sum_triple'), fn.SUM(StratPlay.homerun).alias('sum_hr'), fn.SUM(StratPlay.bb).alias('sum_bb'), fn.SUM(StratPlay.so).alias('sum_so'), fn.SUM(StratPlay.wpa).alias('sum_wpa'), @@ -620,7 +616,7 @@ async def get_pitching_totals( this_game = x.game_id if short_output else model_to_dict(x.game, recurse=False) this_dec = all_dec.where((Decision.pitcher == x.pitcher) & (Decision.game == x.game)) - lob_all_rate, lob_2outs_rate = 0, 0 + lob_all_rate, lob_2outs_rate, rbi_rate = 0, 0, 0 if x.count_runner1 + x.count_runner2 + x.count_runner3 > 0: lob_all_rate = (x.count_lo1 + x.count_lo2 + x.count_lo3) / \ (x.count_runner1 + x.count_runner2 + x.count_runner3) @@ -669,7 +665,7 @@ async def get_pitching_totals( 'slg': slg, 'ops': obp + slg, 'woba': (.69 * x.sum_bb + .72 * x.sum_hbp + .89 * (x.sum_hit - x.sum_double - x.sum_triple - x.sum_hr) + - 1.27 * x.sum_double + 1.62 * x.sum_triple + 2.1 * x.sum_hr) / (x.sum_pa - x.sum_ibb), + 1.27 * x.sum_double + 1.62 * x.sum_triple + 2.1 * x.sum_hr) / max(x.sum_pa - x.sum_ibb, 1), 'k/9': x.sum_so * 9 / (tot_outs / 3), 'bb/9': x.sum_bb * 9 / (tot_outs / 3), 'k/bb': x.sum_so / tot_bb,