fix: replace deprecated Pydantic .dict() with .model_dump() (#76) #90
@ -171,7 +171,7 @@ async def post_award(award_list: AwardList, token: str = Depends(oauth2_scheme))
|
|||||||
status_code=404, detail=f"Team ID {x.team_id} not found"
|
status_code=404, detail=f"Team ID {x.team_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
new_awards.append(x.dict())
|
new_awards.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_awards, 15):
|
for batch in chunked(new_awards, 15):
|
||||||
|
|||||||
@ -366,7 +366,9 @@ async def patch_batstats(
|
|||||||
if BattingStat.get_or_none(BattingStat.id == stat_id) is None:
|
if BattingStat.get_or_none(BattingStat.id == stat_id) is None:
|
||||||
raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found")
|
raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found")
|
||||||
|
|
||||||
BattingStat.update(**new_stats.dict()).where(BattingStat.id == stat_id).execute()
|
BattingStat.update(**new_stats.model_dump()).where(
|
||||||
|
BattingStat.id == stat_id
|
||||||
|
).execute()
|
||||||
r_stat = model_to_dict(BattingStat.get_by_id(stat_id))
|
r_stat = model_to_dict(BattingStat.get_by_id(stat_id))
|
||||||
db.close()
|
db.close()
|
||||||
return r_stat
|
return r_stat
|
||||||
@ -404,7 +406,7 @@ async def post_batstats(s_list: BatStatList, token: str = Depends(oauth2_scheme)
|
|||||||
status_code=404, detail=f"Player ID {x.player_id} not found"
|
status_code=404, detail=f"Player ID {x.player_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
all_stats.append(BattingStat(**x.dict()))
|
all_stats.append(BattingStat(**x.model_dump()))
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(all_stats, 15):
|
for batch in chunked(all_stats, 15):
|
||||||
|
|||||||
@ -116,7 +116,7 @@ async def post_current(new_current: CurrentModel, token: str = Depends(oauth2_sc
|
|||||||
logger.warning(f"patch_current - Bad Token: {token}")
|
logger.warning(f"patch_current - Bad Token: {token}")
|
||||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
|
|
||||||
this_current = Current(**new_current.dict())
|
this_current = Current(**new_current.model_dump())
|
||||||
|
|
||||||
if this_current.save():
|
if this_current.save():
|
||||||
r_curr = model_to_dict(this_current)
|
r_curr = model_to_dict(this_current)
|
||||||
|
|||||||
@ -222,7 +222,7 @@ async def post_decisions(dec_list: DecisionList, token: str = Depends(oauth2_sch
|
|||||||
status_code=404, detail=f"Player ID {x.pitcher_id} not found"
|
status_code=404, detail=f"Player ID {x.pitcher_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
new_dec.append(x.dict())
|
new_dec.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_dec, 10):
|
for batch in chunked(new_dec, 10):
|
||||||
|
|||||||
@ -117,7 +117,7 @@ async def post_division(
|
|||||||
logger.warning(f"post_division - Bad Token: {token}")
|
logger.warning(f"post_division - Bad Token: {token}")
|
||||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
|
|
||||||
this_division = Division(**new_division.dict())
|
this_division = Division(**new_division.model_dump())
|
||||||
|
|
||||||
if this_division.save() == 1:
|
if this_division.save() == 1:
|
||||||
r_division = model_to_dict(this_division)
|
r_division = model_to_dict(this_division)
|
||||||
|
|||||||
@ -93,7 +93,7 @@ async def post_draftlist(
|
|||||||
DraftList.delete().where(DraftList.team == this_team).execute()
|
DraftList.delete().where(DraftList.team == this_team).execute()
|
||||||
|
|
||||||
for x in draft_list.draft_list:
|
for x in draft_list.draft_list:
|
||||||
new_list.append(x.dict())
|
new_list.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_list, 15):
|
for batch in chunked(new_list, 15):
|
||||||
|
|||||||
@ -151,7 +151,7 @@ async def patch_pick(
|
|||||||
if DraftPick.get_or_none(DraftPick.id == pick_id) is None:
|
if DraftPick.get_or_none(DraftPick.id == pick_id) is None:
|
||||||
raise HTTPException(status_code=404, detail=f"Pick ID {pick_id} not found")
|
raise HTTPException(status_code=404, detail=f"Pick ID {pick_id} not found")
|
||||||
|
|
||||||
DraftPick.update(**new_pick.dict()).where(DraftPick.id == pick_id).execute()
|
DraftPick.update(**new_pick.model_dump()).where(DraftPick.id == pick_id).execute()
|
||||||
r_pick = model_to_dict(DraftPick.get_by_id(pick_id))
|
r_pick = model_to_dict(DraftPick.get_by_id(pick_id))
|
||||||
db.close()
|
db.close()
|
||||||
return r_pick
|
return r_pick
|
||||||
@ -176,7 +176,7 @@ async def post_picks(p_list: DraftPickList, token: str = Depends(oauth2_scheme))
|
|||||||
detail=f"Pick # {pick.overall} already exists for season {pick.season}",
|
detail=f"Pick # {pick.overall} already exists for season {pick.season}",
|
||||||
)
|
)
|
||||||
|
|
||||||
new_picks.append(pick.dict())
|
new_picks.append(pick.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_picks, 15):
|
for batch in chunked(new_picks, 15):
|
||||||
|
|||||||
@ -109,7 +109,7 @@ async def post_injury(new_injury: InjuryModel, token: str = Depends(oauth2_schem
|
|||||||
logger.warning(f"post_injury - Bad Token: {token}")
|
logger.warning(f"post_injury - Bad Token: {token}")
|
||||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
|
|
||||||
this_injury = Injury(**new_injury.dict())
|
this_injury = Injury(**new_injury.model_dump())
|
||||||
|
|
||||||
if this_injury.save():
|
if this_injury.save():
|
||||||
r_injury = model_to_dict(this_injury)
|
r_injury = model_to_dict(this_injury)
|
||||||
|
|||||||
@ -96,7 +96,7 @@ async def post_keepers(k_list: KeeperList, token: str = Depends(oauth2_scheme)):
|
|||||||
|
|
||||||
new_keepers = []
|
new_keepers = []
|
||||||
for keeper in k_list.keepers:
|
for keeper in k_list.keepers:
|
||||||
new_keepers.append(keeper.dict())
|
new_keepers.append(keeper.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_keepers, 14):
|
for batch in chunked(new_keepers, 14):
|
||||||
|
|||||||
@ -140,7 +140,7 @@ async def post_manager(new_manager: ManagerModel, token: str = Depends(oauth2_sc
|
|||||||
logger.warning(f"post_manager - Bad Token: {token}")
|
logger.warning(f"post_manager - Bad Token: {token}")
|
||||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
|
|
||||||
this_manager = Manager(**new_manager.dict())
|
this_manager = Manager(**new_manager.model_dump())
|
||||||
|
|
||||||
if this_manager.save():
|
if this_manager.save():
|
||||||
r_manager = model_to_dict(this_manager)
|
r_manager = model_to_dict(this_manager)
|
||||||
|
|||||||
@ -317,7 +317,9 @@ async def patch_pitstats(
|
|||||||
if PitchingStat.get_or_none(PitchingStat.id == stat_id) is None:
|
if PitchingStat.get_or_none(PitchingStat.id == stat_id) is None:
|
||||||
raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found")
|
raise HTTPException(status_code=404, detail=f"Stat ID {stat_id} not found")
|
||||||
|
|
||||||
PitchingStat.update(**new_stats.dict()).where(PitchingStat.id == stat_id).execute()
|
PitchingStat.update(**new_stats.model_dump()).where(
|
||||||
|
PitchingStat.id == stat_id
|
||||||
|
).execute()
|
||||||
r_stat = model_to_dict(PitchingStat.get_by_id(stat_id))
|
r_stat = model_to_dict(PitchingStat.get_by_id(stat_id))
|
||||||
db.close()
|
db.close()
|
||||||
return r_stat
|
return r_stat
|
||||||
@ -344,7 +346,7 @@ async def post_pitstats(s_list: PitStatList, token: str = Depends(oauth2_scheme)
|
|||||||
status_code=404, detail=f"Player ID {x.player_id} not found"
|
status_code=404, detail=f"Player ID {x.player_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
all_stats.append(PitchingStat(**x.dict()))
|
all_stats.append(PitchingStat(**x.model_dump()))
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(all_stats, 15):
|
for batch in chunked(all_stats, 15):
|
||||||
|
|||||||
@ -180,7 +180,7 @@ async def post_results(result_list: ResultList, token: str = Depends(oauth2_sche
|
|||||||
status_code=404, detail=f"Team ID {x.hometeam_id} not found"
|
status_code=404, detail=f"Team ID {x.hometeam_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
new_results.append(x.dict())
|
new_results.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_results, 15):
|
for batch in chunked(new_results, 15):
|
||||||
|
|||||||
@ -242,7 +242,7 @@ async def post_one_player(player: SbaPlayerModel, token: str = Depends(oauth2_sc
|
|||||||
detail=f"{player.first_name} {player.last_name} has a key already in the database",
|
detail=f"{player.first_name} {player.last_name} has a key already in the database",
|
||||||
)
|
)
|
||||||
|
|
||||||
new_player = SbaPlayer(**player.dict())
|
new_player = SbaPlayer(**player.model_dump())
|
||||||
saved = new_player.save()
|
saved = new_player.save()
|
||||||
if saved == 1:
|
if saved == 1:
|
||||||
return_val = model_to_dict(new_player)
|
return_val = model_to_dict(new_player)
|
||||||
|
|||||||
@ -165,7 +165,7 @@ async def post_schedules(sched_list: ScheduleList, token: str = Depends(oauth2_s
|
|||||||
status_code=404, detail=f"Team ID {x.hometeam_id} not found"
|
status_code=404, detail=f"Team ID {x.hometeam_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
new_sched.append(x.dict())
|
new_sched.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_sched, 15):
|
for batch in chunked(new_sched, 15):
|
||||||
|
|||||||
@ -248,7 +248,7 @@ async def post_games(game_list: GameList, token: str = Depends(oauth2_scheme)) -
|
|||||||
status_code=404, detail=f"Team ID {x.home_team_id} not found"
|
status_code=404, detail=f"Team ID {x.home_team_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
new_games.append(x.dict())
|
new_games.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_games, 16):
|
for batch in chunked(new_games, 16):
|
||||||
|
|||||||
@ -40,7 +40,7 @@ async def patch_play(
|
|||||||
db.close()
|
db.close()
|
||||||
raise HTTPException(status_code=404, detail=f"Play ID {play_id} not found")
|
raise HTTPException(status_code=404, detail=f"Play ID {play_id} not found")
|
||||||
|
|
||||||
StratPlay.update(**new_play.dict()).where(StratPlay.id == play_id).execute()
|
StratPlay.update(**new_play.model_dump()).where(StratPlay.id == play_id).execute()
|
||||||
r_play = model_to_dict(StratPlay.get_by_id(play_id))
|
r_play = model_to_dict(StratPlay.get_by_id(play_id))
|
||||||
db.close()
|
db.close()
|
||||||
return r_play
|
return r_play
|
||||||
@ -88,7 +88,7 @@ async def post_plays(p_list: PlayList, token: str = Depends(oauth2_scheme)):
|
|||||||
if this_play.pa == 0:
|
if this_play.pa == 0:
|
||||||
this_play.batter_final = None
|
this_play.batter_final = None
|
||||||
|
|
||||||
new_plays.append(this_play.dict())
|
new_plays.append(this_play.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(new_plays, 20):
|
for batch in chunked(new_plays, 20):
|
||||||
|
|||||||
@ -172,7 +172,7 @@ async def post_transactions(
|
|||||||
status_code=404, detail=f"Player ID {x.player_id} not found"
|
status_code=404, detail=f"Player ID {x.player_id} not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
all_moves.append(x.dict())
|
all_moves.append(x.model_dump())
|
||||||
|
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
for batch in chunked(all_moves, 15):
|
for batch in chunked(all_moves, 15):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user