From 392833a5d9dbd5df371a908fb5a6c915832a252d Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 26 Jan 2026 22:01:38 -0600 Subject: [PATCH] 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. --- app/routers_v2/decisions.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/routers_v2/decisions.py b/app/routers_v2/decisions.py index f8f66bd..560f2e7 100644 --- a/app/routers_v2/decisions.py +++ b/app/routers_v2/decisions.py @@ -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( - StratPlay.pitcher, - StratPlay.game, - fn.SUM(StratPlay.outs).alias("sum_outs"), - ).where((StratPlay.game == x.game) & (StratPlay.pitcher == x.pitcher)) + this_line = ( + StratPlay.select( + StratPlay.pitcher, + StratPlay.game, + fn.SUM(StratPlay.outs).alias("sum_outs"), + ) + .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)