Add missing GROUP BY to decisions/rest endpoint for PostgreSQL

PostgreSQL requires GROUP BY for all non-aggregated columns when using
aggregate functions. Added group_by(pitcher, game) to the StratPlay query
that calculates pitcher innings in the /decisions/rest endpoint.
This commit is contained in:
Cal Corum 2026-01-26 22:01:38 -06:00
parent 92fc101e38
commit 392833a5d9

View File

@ -170,11 +170,15 @@ async def get_decisions_for_rest(
this_val.append(this_card.id if this_card is not None else -1)
this_val.append(1 if x.is_start else 0)
if not native_rest:
this_line = StratPlay.select(
this_line = (
StratPlay.select(
StratPlay.pitcher,
StratPlay.game,
fn.SUM(StratPlay.outs).alias("sum_outs"),
).where((StratPlay.game == x.game) & (StratPlay.pitcher == x.pitcher))
)
.where((StratPlay.game == x.game) & (StratPlay.pitcher == x.pitcher))
.group_by(StratPlay.pitcher, StratPlay.game)
)
logging.info(f"this_line: {this_line[0]}")
if this_line[0].sum_outs is None:
this_val.append(0.0)