Standardize formatting with black and apply ruff auto-fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
"""
|
|
Fix player names by removing asterisks (*) and hash symbols (#) from cardset 27
|
|
"""
|
|
|
|
import asyncio
|
|
from db_calls import db_get, db_patch
|
|
|
|
CARDSET_ID = 27
|
|
|
|
|
|
async def fix_player_names():
|
|
print(f"Fetching all players from cardset {CARDSET_ID}...")
|
|
|
|
# Get all players from cardset
|
|
response = await db_get(
|
|
"players", params=[("cardset_id", CARDSET_ID), ("page_size", 500)]
|
|
)
|
|
|
|
# Handle different response structures
|
|
if "players" in response:
|
|
all_players = response["players"]
|
|
elif "results" in response:
|
|
all_players = response["results"]
|
|
else:
|
|
print(f"Error: Unexpected response structure. Response keys: {response.keys()}")
|
|
return
|
|
print(f"Found {len(all_players)} players")
|
|
|
|
# Track what we're fixing
|
|
fixed_count = 0
|
|
skipped_count = 0
|
|
|
|
for player in all_players:
|
|
player_id = player["player_id"]
|
|
original_name = player["p_name"]
|
|
|
|
# Check if name has asterisk or hash
|
|
if "*" in original_name or "#" in original_name:
|
|
# Remove the symbols
|
|
clean_name = original_name.replace("*", "").replace("#", "").strip()
|
|
|
|
print(f"Fixing player {player_id}: '{original_name}' -> '{clean_name}'")
|
|
|
|
# PATCH the player (API expects 'name' parameter, not 'p_name')
|
|
result = await db_patch(
|
|
"players", object_id=player_id, params=[("name", clean_name)]
|
|
)
|
|
|
|
if "player_id" in result or "id" in result:
|
|
fixed_count += 1
|
|
else:
|
|
print(f" ERROR patching player {player_id}: {result}")
|
|
else:
|
|
skipped_count += 1
|
|
|
|
print(f"\n{'='*60}")
|
|
print("SUMMARY")
|
|
print(f"{'='*60}")
|
|
print(f"Fixed: {fixed_count} players")
|
|
print(f"Skipped (no symbols): {skipped_count} players")
|
|
print(f"Total: {len(all_players)} players")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(fix_player_names())
|