Indicators: the history chart and the KPI card read the total when a measure publishes more groups

This commit is contained in:
2026-11-13 21:15:47 -06:00
parent b42428b068
commit 4ffd3797b6
5 changed files with 33 additions and 6 deletions
@@ -63,6 +63,14 @@ export interface PlotlyFigure {
export type Tema = 'claro' | 'oscuro';
export interface FigureSelection { dominio?: Dominio; tipoPeriodo?: TipoPeriodo; indicador: string; figura: string; tema: Tema; periodos?: string[]; }
// A measure may publish more groups next to `group` (TEA's EEG result: one per alteration). The rows without those
// of the other published groups; a row of a group nobody published stays, for the caller to refuse.
export function filasDelGrupo(data: IndicadorDatos, group: string): Record<string, unknown>[] {
const published = data['grupos'];
const others = new Set(Object.keys(published && typeof published === 'object' ? published : {}).filter(id => id !== group));
return others.size ? data.filas.filter(row => !others.has(row['grupo'] as string)) : data.filas;
}
export function parsePeriodos(value: string, tipo: TipoPeriodo = 'semestre'): string[] | null {
if (tipo !== 'semestre' && tipo !== 'mes') return null;
const parts = value.split(',').map(part => part.trim());