Screening route: without a requested period, open on the newest one that has published boxes

A semester that has just begun has no events and the chart opened on it, empty, while earlier ones had data.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit a15e37ed77)
This commit is contained in:
2026-11-22 03:28:05 -06:00
committed by Angel Capetillo Zavala
parent 7692952ec9
commit 17cef51d90
2 changed files with 10 additions and 1 deletions
@@ -66,7 +66,9 @@ export function routeModel(data: Record<string, IndicadorDatos>, tipo: TipoPerio
}
}
const periods = [...new Set(ROUTE_IDS.flatMap(id => data[id].periodos))].sort().reverse();
const period = requested && periods.includes(requested) ? requested : periods[0];
// Without a valid request the newest period that has a published box: a semester that has just begun is empty.
const hasData = (p: string) => ROUTE_IDS.some(id => boxes[id][p]?.estado === 'Publicado');
const period = requested && periods.includes(requested) ? requested : periods.find(hasData) ?? periods[0];
let cursor = 0;
const rows = ROUTE_STEPS.map((step): RouteRow => {
const fromSample = period ? boxes[step.sinceSample][period] ?? NOT_AVAILABLE : NOT_AVAILABLE;