63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
||
"""Update celestial_type_configs to use unified ratio"""
|
||
import asyncio
|
||
import sys
|
||
import os
|
||
import json
|
||
|
||
sys.path.append(os.path.join(os.getcwd(), "backend"))
|
||
|
||
from app.database import AsyncSessionLocal
|
||
from app.services.system_settings_service import system_settings_service
|
||
|
||
# Unified ratio for all types
|
||
# This ensures consistent scaling based on real physical size
|
||
UNIFIED_RATIO = 0.00008
|
||
|
||
async def update_unified_ratio():
|
||
"""Update all type ratios to use unified value"""
|
||
async with AsyncSessionLocal() as session:
|
||
# Get current config
|
||
current_config = await system_settings_service.get_setting_value('celestial_type_configs', session)
|
||
|
||
print("=" * 70)
|
||
print("CURRENT celestial_type_configs:")
|
||
print("=" * 70)
|
||
print(json.dumps(current_config, indent=2))
|
||
|
||
# Update all ratios to unified value
|
||
updated_config = {}
|
||
for body_type, config in current_config.items():
|
||
updated_config[body_type] = {
|
||
'ratio': UNIFIED_RATIO,
|
||
'default': config.get('default', 0.5) # Keep existing defaults
|
||
}
|
||
|
||
print("\n" + "=" * 70)
|
||
print(f"UPDATED celestial_type_configs (unified ratio = {UNIFIED_RATIO}):")
|
||
print("=" * 70)
|
||
print(json.dumps(updated_config, indent=2))
|
||
|
||
# Save updated config
|
||
await system_settings_service.update_setting(
|
||
'celestial_type_configs',
|
||
updated_config,
|
||
session
|
||
)
|
||
|
||
await session.commit()
|
||
|
||
print("\n" + "=" * 70)
|
||
print("✅ All type ratios unified successfully!")
|
||
print("=" * 70)
|
||
print("\nNOW ALL BODIES WILL USE:")
|
||
print(f" Display Size = real_radius (km) × {UNIFIED_RATIO}")
|
||
print("\nThis ensures:")
|
||
print(" • Consistent scaling across all body types")
|
||
print(" • Jupiter is correctly 10.97x larger than Earth")
|
||
print(" • Ceres is correctly 0.07x the size of Earth")
|
||
print(" • Pluto is correctly 0.19x the size of Earth")
|
||
|
||
if __name__ == "__main__":
|
||
asyncio.run(update_unified_ratio())
|