fix: remove commented-out dead code blocks (#31) #48

Merged
cal merged 1 commits from ai/major-domo-database-31 into next-release 2026-04-08 03:40:43 +00:00
5 changed files with 35 additions and 62 deletions

View File

@ -45,15 +45,6 @@ date = f"{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetim
logger = logging.getLogger("discord_app") logger = logging.getLogger("discord_app")
"""
Per season updates:
Result: regular_season & post_season - set season length
update_standings - confirm division alignments and records
Standings: recalculate - e_number function, set season length
- wildcard section, set league abbrevs
"""
def model_csv_headers(this_obj, exclude=None) -> List: def model_csv_headers(this_obj, exclude=None) -> List:
data = model_to_dict(this_obj, recurse=False, exclude=exclude) data = model_to_dict(this_obj, recurse=False, exclude=exclude)
return [x for x in data.keys()] return [x for x in data.keys()]
@ -206,22 +197,6 @@ class Division(BaseModel):
# Assign div_gb and e_num # Assign div_gb and e_num
for x in range(len(div_teams)): for x in range(len(div_teams)):
# # Used for two playoff teams per divsion
# # Special calculations for the division leader
# if x == 0:
# div_teams[0].div_gb = -games_back(div_teams[0], div_teams[2])
# div_teams[0].div_e_num = None
# div_teams[0].wc_gb = None
# div_teams[0].wc_e_num = None
# elif x == 1:
# div_teams[1].div_gb = 0
# div_teams[1].div_e_num = None
# div_teams[1].wc_gb = None
# div_teams[1].wc_e_num = None
# else:
# div_teams[x].div_gb = games_back(div_teams[1], div_teams[x])
# div_teams[x].div_e_num = e_number(div_teams[1], div_teams[x])
# Used for one playoff team per division
if x == 0: if x == 0:
div_teams[0].div_gb = None div_teams[0].div_gb = None
div_teams[0].div_e_num = None div_teams[0].div_e_num = None

View File

@ -14,13 +14,6 @@ from redis import Redis
date = f"{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}" date = f"{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}"
logger = logging.getLogger("discord_app") logger = logging.getLogger("discord_app")
# date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}'
# log_level = logger.info if os.environ.get('LOG_LEVEL') == 'INFO' else 'WARN'
# logging.basicConfig(
# filename=f'logs/database/{date}.log',
# format='%(asctime)s - sba-database - %(levelname)s - %(message)s',
# level=log_level
# )
# Discord integration # Discord integration
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL") DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")

View File

@ -8,9 +8,6 @@ from fastapi import Depends, FastAPI, Request
from fastapi.openapi.docs import get_swagger_ui_html from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.openapi.utils import get_openapi from fastapi.openapi.utils import get_openapi
# from fastapi.openapi.docs import get_swagger_ui_html
# from fastapi.openapi.utils import get_openapi
from .routers_v3 import ( from .routers_v3 import (
current, current,
players, players,
@ -39,13 +36,35 @@ from .routers_v3 import (
views, views,
) )
# date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}' from .routers_v3 import (
current,
players,
results,
schedules,
standings,
teams,
transactions,
battingstats,
pitchingstats,
fieldingstats,
draftpicks,
draftlist,
managers,
awards,
draftdata,
keepers,
stratgame,
stratplay,
injuries,
decisions,
divisions,
sbaplayers,
custom_commands,
help_commands,
views,
)
log_level = logging.INFO if os.environ.get("LOG_LEVEL") == "INFO" else logging.WARNING log_level = logging.INFO if os.environ.get("LOG_LEVEL") == "INFO" else logging.WARNING
# logging.basicConfig(
# filename=f'logs/database/{date}.log',
# format='%(asctime)s - sba-database - %(levelname)s - %(message)s',
# level=log_level
# )
logger = logging.getLogger("discord_app") logger = logging.getLogger("discord_app")
logger.setLevel(log_level) logger.setLevel(log_level)
@ -138,7 +157,3 @@ async def get_docs(req: Request):
async def openapi(): async def openapi():
return get_openapi(title="SBa API Docs", version=f"0.1.1", routes=app.routes) return get_openapi(title="SBa API Docs", version=f"0.1.1", routes=app.routes)
# @app.get("/api")
# async def root():
# return {"message": "Hello Bigger Applications!"}

View File

@ -93,14 +93,17 @@ async def get_batstats(
if "post" in s_type.lower(): if "post" in s_type.lower():
all_stats = BattingStat.post_season(season) all_stats = BattingStat.post_season(season)
if all_stats.count() == 0: if all_stats.count() == 0:
return {"count": 0, "stats": []} return {"count": 0, "stats": []}
elif s_type.lower() in ["combined", "total", "all"]: elif s_type.lower() in ["combined", "total", "all"]:
all_stats = BattingStat.combined_season(season) all_stats = BattingStat.combined_season(season)
if all_stats.count() == 0: if all_stats.count() == 0:
return {"count": 0, "stats": []} return {"count": 0, "stats": []}
else: else:
all_stats = BattingStat.regular_season(season) all_stats = BattingStat.regular_season(season)
if all_stats.count() == 0: if all_stats.count() == 0:
return {"count": 0, "stats": []} return {"count": 0, "stats": []}
if position is not None: if position is not None:
@ -348,11 +351,6 @@ async def get_totalstats(
return return_stats return return_stats
# @router.get('/career/{player_name}')
# async def get_careerstats(
# s_type: Literal['regular', 'post', 'total'] = 'regular', player_name: list = Query(default=None)):
# pass # Keep Career Stats table and recalculate after posting stats
@router.patch("/{stat_id}", include_in_schema=PRIVATE_IN_SCHEMA) @router.patch("/{stat_id}", include_in_schema=PRIVATE_IN_SCHEMA)
@handle_db_errors @handle_db_errors

View File

@ -92,15 +92,6 @@ async def get_decisions(
all_dec = all_dec.where(Decision.game_id << game_id) all_dec = all_dec.where(Decision.game_id << game_id)
if player_id is not None: if player_id is not None:
all_dec = all_dec.where(Decision.pitcher << player_id) all_dec = all_dec.where(Decision.pitcher << player_id)
# # Need to allow for split-season stats
# if team_id is not None:
# all_teams = Team.select().where(Team.id << team_id)
# all_games = StratGame.select().where(
# (StratGame.away_team << all_teams) | (StratGame.home_team << all_teams))
# all_dec = all_dec.where(Decision.game << all_games)
# if team_id is not None:
# all_players = Player.select().where(Player.team_id << team_id)
# all_dec = all_dec.where(Decision.pitcher << all_players)
if team_id is not None: if team_id is not None:
s8_teams = [int(x) for x in team_id if int(x) <= 350] s8_teams = [int(x) for x in team_id if int(x) <= 350]
if season is not None and 8 in season or s8_teams: if season is not None and 8 in season or s8_teams:
@ -115,9 +106,6 @@ async def get_decisions(
if s_type is not None: if s_type is not None:
all_games = StratGame.select().where(StratGame.season_type == s_type) all_games = StratGame.select().where(StratGame.season_type == s_type)
all_dec = all_dec.where(Decision.game << all_games) all_dec = all_dec.where(Decision.game << all_games)
# if team_id is not None:
# all_players = Player.select().where(Player.team_id << team_id)
# all_dec = all_dec.where(Decision.pitcher << all_players)
if week_start is not None: if week_start is not None:
all_dec = all_dec.where(Decision.week >= week_start) all_dec = all_dec.where(Decision.week >= week_start)
if week_end is not None: if week_end is not None:
@ -167,6 +155,7 @@ async def patch_decision(
this_dec = Decision.get_or_none(Decision.id == decision_id) this_dec = Decision.get_or_none(Decision.id == decision_id)
if this_dec is None: if this_dec is None:
raise HTTPException( raise HTTPException(
status_code=404, detail=f"Decision ID {decision_id} not found" status_code=404, detail=f"Decision ID {decision_id} not found"
) )
@ -194,6 +183,7 @@ async def patch_decision(
d_result = model_to_dict(this_dec) d_result = model_to_dict(this_dec)
return d_result return d_result
else: else:
raise HTTPException( raise HTTPException(
status_code=500, detail=f"Unable to patch decision {decision_id}" status_code=500, detail=f"Unable to patch decision {decision_id}"
) )
@ -235,6 +225,7 @@ async def delete_decision(decision_id: int, token: str = Depends(oauth2_scheme))
this_dec = Decision.get_or_none(Decision.id == decision_id) this_dec = Decision.get_or_none(Decision.id == decision_id)
if this_dec is None: if this_dec is None:
raise HTTPException( raise HTTPException(
status_code=404, detail=f"Decision ID {decision_id} not found" status_code=404, detail=f"Decision ID {decision_id} not found"
) )
@ -258,6 +249,7 @@ async def delete_decisions_game(game_id: int, token: str = Depends(oauth2_scheme
this_game = StratGame.get_or_none(StratGame.id == game_id) this_game = StratGame.get_or_none(StratGame.id == game_id)
if not this_game: if not this_game:
raise HTTPException(status_code=404, detail=f"Game ID {game_id} not found") raise HTTPException(status_code=404, detail=f"Game ID {game_id} not found")
count = Decision.delete().where(Decision.game == this_game).execute() count = Decision.delete().where(Decision.game == this_game).execute()