main
mula.liu 2025-12-29 09:52:37 +08:00
parent a09c725a03
commit ed7f2458f7
1 changed files with 11 additions and 5 deletions

View File

@ -326,19 +326,25 @@ async def get_celestial_positions(
logger.debug(f"Skipping inactive probe {body.name} with no data for {start_dt_naive}") logger.debug(f"Skipping inactive probe {body.name} with no data for {start_dt_naive}")
continue continue
# Missing data for active body - need to query Horizons # Missing data for active body - mark as incomplete but continue
logger.debug(f"Missing position data for {body.name} ({body.type})")
has_complete_data = False has_complete_data = False
break # Don't break - continue to collect data for other bodies
# Return data we have, even if incomplete
if all_bodies_positions:
if has_complete_data:
logger.info(f"Using complete prefetched data from positions table ({len(all_bodies_positions)} bodies)")
else:
logger.info(f"Using partial prefetched data from positions table ({len(all_bodies_positions)} bodies, some data missing)")
if has_complete_data and all_bodies_positions:
logger.info(f"Using prefetched historical data from positions table ({len(all_bodies_positions)} bodies)")
# Cache in memory # Cache in memory
cache_service.set(all_bodies_positions, start_dt, end_dt, step) cache_service.set(all_bodies_positions, start_dt, end_dt, step)
# Cache in Redis for faster access next time # Cache in Redis for faster access next time
await redis_cache.set(redis_key, all_bodies_positions, get_ttl_seconds("historical_positions")) await redis_cache.set(redis_key, all_bodies_positions, get_ttl_seconds("historical_positions"))
return CelestialDataResponse(bodies=all_bodies_positions) return CelestialDataResponse(bodies=all_bodies_positions)
else: else:
logger.info("Incomplete historical data in positions table, falling back to Horizons") logger.info("No historical data found in positions table")
# Check if auto download is enabled # Check if auto download is enabled
auto_download_enabled = await system_settings_service.get_setting_value("auto_download_positions", db) auto_download_enabled = await system_settings_service.get_setting_value("auto_download_positions", db)