major-domo-database/.claude/sqlite-to-postgres/quick_data_comparison.py
Cal Corum 7130a1fd43 Postgres Migration
Migration documentation and scripts
2025-08-25 07:18:31 -05:00

115 lines
4.0 KiB
Python

#!/usr/bin/env python3
"""
Quick Data Comparison Script
Simple script to quickly compare specific data points between localhost and production APIs.
Useful for manual testing and debugging specific issues.
Usage:
python quick_data_comparison.py
"""
import requests
import json
LOCALHOST_API = "http://localhost:801/api/v3"
PRODUCTION_API = "https://sba.manticorum.com/api/v3"
def compare_player(player_id):
"""Compare a specific player between APIs"""
print(f"\n=== PLAYER {player_id} COMPARISON ===")
try:
# Localhost
local_resp = requests.get(f"{LOCALHOST_API}/players/{player_id}", timeout=10)
local_data = local_resp.json() if local_resp.status_code == 200 else {"error": local_resp.status_code}
# Production
prod_resp = requests.get(f"{PRODUCTION_API}/players/{player_id}", timeout=10)
prod_data = prod_resp.json() if prod_resp.status_code == 200 else {"error": prod_resp.status_code}
print(f"Localhost: {local_data.get('name', 'ERROR')} ({local_data.get('pos_1', 'N/A')})")
print(f"Production: {prod_data.get('name', 'ERROR')} ({prod_data.get('pos_1', 'N/A')})")
if local_data.get('name') != prod_data.get('name'):
print("❌ MISMATCH DETECTED!")
else:
print("✅ Names match")
except Exception as e:
print(f"❌ Error: {e}")
def compare_batting_stats(params):
"""Compare batting stats with given parameters"""
print(f"\n=== BATTING STATS COMPARISON ===")
print(f"Parameters: {params}")
try:
# Localhost
local_resp = requests.get(f"{LOCALHOST_API}/plays/batting", params=params, timeout=10)
if local_resp.status_code == 200:
local_data = local_resp.json()
local_count = local_data.get('count', 0)
local_top = local_data.get('stats', [])[:3] # Top 3
else:
local_count = f"ERROR {local_resp.status_code}"
local_top = []
# Production
prod_resp = requests.get(f"{PRODUCTION_API}/plays/batting", params=params, timeout=10)
if prod_resp.status_code == 200:
prod_data = prod_resp.json()
prod_count = prod_data.get('count', 0)
prod_top = prod_data.get('stats', [])[:3] # Top 3
else:
prod_count = f"ERROR {prod_resp.status_code}"
prod_top = []
print(f"Localhost count: {local_count}")
print(f"Production count: {prod_count}")
print("\nTop 3 Players:")
print("Localhost:")
for i, stat in enumerate(local_top):
player = stat.get('player', {})
print(f" {i+1}. {player.get('name', 'Unknown')} ({player.get('id', 'N/A')}) - RE24: {stat.get('re24_primary', 'N/A')}")
print("Production:")
for i, stat in enumerate(prod_top):
player = stat.get('player', {})
print(f" {i+1}. {player.get('name', 'Unknown')} ({player.get('id', 'N/A')}) - RE24: {stat.get('re24_primary', 'N/A')}")
except Exception as e:
print(f"❌ Error: {e}")
def main():
"""Run quick comparisons"""
print("🔍 QUICK DATA COMPARISON TOOL")
print("=" * 40)
# Test the known problematic players
print("\n📊 TESTING KNOWN PROBLEMATIC PLAYERS:")
compare_player(9916) # Should be Marcell Ozuna vs Trevor Williams
compare_player(9958) # Should be Michael Harris vs Xavier Edwards
# Test the original problematic query
print("\n📊 TESTING BASES LOADED BATTING (OBC=111):")
compare_batting_stats({
'season': 10,
'group_by': 'playerteam',
'limit': 10,
'obc': '111',
'sort': 'repri-desc'
})
# Test a simpler query
print("\n📊 TESTING SIMPLE PLAYER BATTING:")
compare_batting_stats({
'season': 10,
'group_by': 'playerteam',
'limit': 5,
'obc': '000' # No runners
})
if __name__ == "__main__":
main()