fix: remove stub live_update_pitching endpoint (#11)

The /live-update/pitching POST endpoint was a placeholder that only
validated auth and returned the input unchanged. No pitching processing
logic existed anywhere in the codebase. Removed the dead endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-04 00:02:55 -06:00
parent 8227b57875
commit 8e0d1e63a3

View File

@ -6,19 +6,15 @@ from ..db_engine import Player
from ..dependencies import oauth2_scheme, valid_token from ..dependencies import oauth2_scheme, valid_token
from ..player_scouting import get_player_ids from ..player_scouting import get_player_ids
router = APIRouter(prefix="/api/v2/scouting", tags=["scouting"])
router = APIRouter(
prefix='/api/v2/scouting',
tags=['scouting']
)
class BattingFiles(pydantic.BaseModel): class BattingFiles(pydantic.BaseModel):
vl_basic: str = 'vl-basic.csv' vl_basic: str = "vl-basic.csv"
vl_rate: str = 'vl-rate.csv' vl_rate: str = "vl-rate.csv"
vr_basic: str = 'vr-basic.csv' vr_basic: str = "vr-basic.csv"
vr_rate: str = 'vr-rate.csv' vr_rate: str = "vr-rate.csv"
running: str = 'running.csv' running: str = "running.csv"
# def csv_file_to_dataframe(filename: str) -> pd.DataFrame | None: # def csv_file_to_dataframe(filename: str) -> pd.DataFrame | None:
@ -28,45 +24,46 @@ class BattingFiles(pydantic.BaseModel):
# for row in reader: # for row in reader:
@router.get('/playerkeys') @router.get("/playerkeys")
async def get_player_keys(player_id: list = Query(default=None)): async def get_player_keys(player_id: list = Query(default=None)):
all_keys = [] all_keys = []
for x in player_id: for x in player_id:
this_player = Player.get_or_none(Player.player_id == x) this_player = Player.get_or_none(Player.player_id == x)
if this_player is not None: if this_player is not None:
this_keys = get_player_ids(this_player.bbref_id, id_type='bbref') this_keys = get_player_ids(this_player.bbref_id, id_type="bbref")
if this_keys is not None: if this_keys is not None:
all_keys.append(this_keys) all_keys.append(this_keys)
return_val = {'count': len(all_keys), 'keys': [ return_val = {"count": len(all_keys), "keys": [dict(x) for x in all_keys]}
dict(x) for x in all_keys
]}
return return_val return return_val
@router.post('/live-update/batting') @router.post("/live-update/batting")
def live_update_batting(files: BattingFiles, cardset_id: int, token: str = Depends(oauth2_scheme)): def live_update_batting(
files: BattingFiles, cardset_id: int, token: str = Depends(oauth2_scheme)
):
if not valid_token(token): if not valid_token(token):
logging.warning('Bad Token: [REDACTED]') logging.warning("Bad Token: [REDACTED]")
raise HTTPException( raise HTTPException(
status_code=401, status_code=401, detail="You are not authorized to initiate live updates."
detail='You are not authorized to initiate live updates.'
) )
data = {} # <fg id>: { 'vL': [combined vl stat data], 'vR': [combined vr stat data] } data = (
{}
) # <fg id>: { 'vL': [combined vl stat data], 'vR': [combined vr stat data] }
for row in files.vl_basic: for row in files.vl_basic:
if row['pa'] >= 20: if row["pa"] >= 20:
data[row['fgid']]['vL'] = row data[row["fgid"]]["vL"] = row
for row in files.vl_rate: for row in files.vl_rate:
if row['fgid'] in data.keys(): if row["fgid"] in data.keys():
data[row['fgid']]['vL'].extend(row) data[row["fgid"]]["vL"].extend(row)
for row in files.vr_basic: for row in files.vr_basic:
if row['pa'] >= 40 and row['fgid'] in data.keys(): if row["pa"] >= 40 and row["fgid"] in data.keys():
data[row['fgid']]['vR'] = row data[row["fgid"]]["vR"] = row
for row in files.vr_rate: for row in files.vr_rate:
if row['fgid'] in data.keys(): if row["fgid"] in data.keys():
data[row['fgid']]['vR'].extend(row) data[row["fgid"]]["vR"].extend(row)
for x in data.items(): for x in data.items():
pass pass
@ -76,15 +73,3 @@ def live_update_batting(files: BattingFiles, cardset_id: int, token: str = Depen
# Read running stats and create/update BattingCard object # Read running stats and create/update BattingCard object
return files.dict() return files.dict()
@router.post('/live-update/pitching')
def live_update_pitching(files: BattingFiles, token: str = Depends(oauth2_scheme)):
if not valid_token(token):
logging.warning('Bad Token: [REDACTED]')
raise HTTPException(
status_code=401,
detail='You are not authorized to initiate live updates.'
)
return files.dict()