#!/usr/bin/env python3 """Check if positions exist in database for Earth""" import asyncio import sys import os from datetime import datetime, timedelta sys.path.append(os.path.join(os.getcwd(), "backend")) from app.database import AsyncSessionLocal from app.services.db_service import position_service async def check_positions(): """Check if we have position data for Earth""" async with AsyncSessionLocal() as session: now = datetime.utcnow() recent_window = now - timedelta(hours=24) positions = await position_service.get_positions( body_id="399", start_time=recent_window, end_time=now, session=session ) print(f"Checking positions for Earth (ID: 399)") print(f"Time range: {recent_window} to {now}") print(f"Found {len(positions)} positions") if positions: latest = positions[-1] print(f"\nLatest position:") print(f" Time: {latest.time}") print(f" X: {latest.x}, Y: {latest.y}, Z: {latest.z}") else: print("\n❌ No recent positions found for Earth!") print("This explains why the API is failing.") if __name__ == "__main__": asyncio.run(check_positions())