62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Add missing real_radius data for solar system bodies"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
|
|
sys.path.append(os.path.join(os.getcwd(), "backend"))
|
|
|
|
from app.database import AsyncSessionLocal
|
|
from app.services.db_service import celestial_body_service
|
|
|
|
# Real radii from NASA data (in km)
|
|
MISSING_RADII = {
|
|
'10': 696000, # Sun
|
|
'999': 1188, # Pluto
|
|
'2000001': 476, # Ceres
|
|
'136199': 1163, # Eris
|
|
'136108': 816, # Haumea
|
|
'136472': 715, # Makemake
|
|
}
|
|
|
|
async def add_missing_radii():
|
|
"""Add real_radius to bodies that are missing it"""
|
|
async with AsyncSessionLocal() as session:
|
|
print("=" * 70)
|
|
print("Adding missing real_radius data")
|
|
print("=" * 70)
|
|
|
|
for body_id, radius in MISSING_RADII.items():
|
|
body = await celestial_body_service.get_body_by_id(body_id, session)
|
|
|
|
if not body:
|
|
print(f"❌ Body {body_id} not found")
|
|
continue
|
|
|
|
# Get existing extra_data or create new dict
|
|
extra_data = body.extra_data.copy() if body.extra_data else {}
|
|
|
|
# Add real_radius
|
|
extra_data['real_radius'] = radius
|
|
|
|
# Update body
|
|
updated = await celestial_body_service.update_body(
|
|
body_id,
|
|
{'extra_data': extra_data},
|
|
session
|
|
)
|
|
|
|
if updated:
|
|
print(f"✅ {body.name:<20} (ID: {body_id:<10}): Added real_radius = {radius:>8} km")
|
|
else:
|
|
print(f"❌ {body.name:<20} (ID: {body_id:<10}): Update failed")
|
|
|
|
await session.commit()
|
|
|
|
print("\n" + "=" * 70)
|
|
print("✅ All missing real_radius data added successfully!")
|
|
print("=" * 70)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(add_missing_radii())
|