Fix historical aggregate snapshots and empty states

This commit is contained in:
devRaGonSa
2026-03-23 14:48:11 +01:00
parent 7a002a0e72
commit f35ce58a84
5 changed files with 289 additions and 46 deletions

View File

@@ -593,6 +593,9 @@ persistida por servidor para releer solo paginas recientes y absorber updates
tardios sin reimportar todo el historico. Cuando una ejecucion termina
correctamente, tambien recompone los snapshots historicos precalculados para el
servidor afectado o para todos los servidores si la ingesta fue global.
Si la recomposicion se lanza para un servidor fisico concreto, el backend
rehace tambien el agregado logico `all-servers` para mantener `Todos`
alineado con `#01` y `#02` aunque `#03` siga sin bootstrap.
El comando devuelve ademas un resumen de cobertura persistida por servidor. Esto
ayuda a validar rapidamente cuantos matches reales quedaron importados, el rango

View File

@@ -161,7 +161,7 @@ def build_all_historical_snapshots(
db_path: Path | None = None,
) -> list[dict[str, object]]:
"""Build the full snapshot set for one server or for all configured servers."""
target_server_keys = [server_key] if server_key else list_snapshot_server_keys(db_path=db_path)
target_server_keys = _resolve_snapshot_target_keys(server_key=server_key, db_path=db_path)
snapshots: list[dict[str, object]] = []
for target_server_key in target_server_keys:
snapshots.extend(
@@ -340,6 +340,24 @@ def _build_recent_matches_snapshot(
}
def _resolve_snapshot_target_keys(
*,
server_key: str | None,
db_path: Path | None = None,
) -> list[str]:
"""Expand targeted rebuilds so the logical global aggregate stays in sync."""
if not server_key:
return list_snapshot_server_keys(db_path=db_path)
normalized_server_key = server_key.strip()
if not normalized_server_key:
return list_snapshot_server_keys(db_path=db_path)
if normalized_server_key == ALL_SERVERS_SLUG:
return [ALL_SERVERS_SLUG]
return [normalized_server_key, ALL_SERVERS_SLUG]
def _parse_optional_timestamp(value: object) -> datetime | None:
if not isinstance(value, str) or not value.strip():
return None