diff --git a/backend/app/api/celestial_position.py b/backend/app/api/celestial_position.py index f632a0b..aa1d11f 100644 --- a/backend/app/api/celestial_position.py +++ b/backend/app/api/celestial_position.py @@ -326,19 +326,25 @@ async def get_celestial_positions( logger.debug(f"Skipping inactive probe {body.name} with no data for {start_dt_naive}") 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 - 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_service.set(all_bodies_positions, start_dt, end_dt, step) # Cache in Redis for faster access next time await redis_cache.set(redis_key, all_bodies_positions, get_ttl_seconds("historical_positions")) return CelestialDataResponse(bodies=all_bodies_positions) 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 auto_download_enabled = await system_settings_service.get_setting_value("auto_download_positions", db)