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:
parent
92fc101e38
commit
392833a5d9
@ -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(this_card.id if this_card is not None else -1)
|
||||||
this_val.append(1 if x.is_start else 0)
|
this_val.append(1 if x.is_start else 0)
|
||||||
if not native_rest:
|
if not native_rest:
|
||||||
this_line = StratPlay.select(
|
this_line = (
|
||||||
StratPlay.pitcher,
|
StratPlay.select(
|
||||||
StratPlay.game,
|
StratPlay.pitcher,
|
||||||
fn.SUM(StratPlay.outs).alias("sum_outs"),
|
StratPlay.game,
|
||||||
).where((StratPlay.game == x.game) & (StratPlay.pitcher == x.pitcher))
|
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]}")
|
logging.info(f"this_line: {this_line[0]}")
|
||||||
if this_line[0].sum_outs is None:
|
if this_line[0].sum_outs is None:
|
||||||
this_val.append(0.0)
|
this_val.append(0.0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user