Standardize formatting with black and apply ruff auto-fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
"""
|
|
Regenerate cards for the 20 left-handed players whose names were just fixed
|
|
Updates image URLs with tomorrow's date to bust cache
|
|
"""
|
|
|
|
import asyncio
|
|
import datetime
|
|
from db_calls import db_patch, DB_URL
|
|
|
|
# List of player IDs that were fixed
|
|
FIXED_PLAYER_IDS = [
|
|
13015, # Terrence Long
|
|
13017, # Jeremy Reed
|
|
13020, # Ben Broussard
|
|
13030, # Carlos Pena
|
|
13032, # Scott Podsednik
|
|
13034, # AJ Pierzynski
|
|
13037, # Brian Schneider
|
|
13045, # Justin Morneau
|
|
13047, # BJ Surhoff
|
|
13048, # Jay Gibbons
|
|
13053, # Eric Hinske
|
|
13058, # Chad Tracy
|
|
13062, # Dave Roberts
|
|
13068, # Daryle Ward
|
|
13070, # Jim Edmonds
|
|
13071, # Larry Walker
|
|
13077, # Adam Dunn
|
|
13082, # Mike Lamb
|
|
13084, # Larry Bigbie
|
|
13090, # Rafael Palmeiro
|
|
]
|
|
|
|
|
|
async def regenerate_cards():
|
|
# Tomorrow's date for cache busting
|
|
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
|
release_date = f"{tomorrow.year}-{tomorrow.month}-{tomorrow.day}"
|
|
|
|
print(f"Regenerating cards with release date: {release_date}\n")
|
|
|
|
success_count = 0
|
|
error_count = 0
|
|
|
|
for player_id in FIXED_PLAYER_IDS:
|
|
try:
|
|
# Build new image URL with tomorrow's date
|
|
batting_card_url = (
|
|
f"{DB_URL}/v2/players/{player_id}/battingcard?d={release_date}"
|
|
)
|
|
|
|
print(f"Updating player {player_id}...")
|
|
|
|
# PATCH the player with new image URL
|
|
result = await db_patch(
|
|
"players", object_id=player_id, params=[("image", batting_card_url)]
|
|
)
|
|
|
|
if "player_id" in result or "id" in result:
|
|
print(f" ✅ Success - {result.get('p_name', 'Unknown')}")
|
|
success_count += 1
|
|
else:
|
|
print(f" ❌ Failed: {result}")
|
|
error_count += 1
|
|
|
|
except Exception as e:
|
|
print(f" ❌ Error: {e}")
|
|
error_count += 1
|
|
|
|
print(f"\n{'='*60}")
|
|
print("SUMMARY")
|
|
print(f"{'='*60}")
|
|
print(f"Successfully updated: {success_count} players")
|
|
print(f"Errors: {error_count} players")
|
|
print(f"Total: {len(FIXED_PLAYER_IDS)} players")
|
|
print(f"{'='*60}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(regenerate_cards())
|