feat(indicadores): completa metadatos y navegación multiperiodo
This commit is contained in:
@@ -30,12 +30,32 @@ export class IndicadoresService {
|
||||
metadatos(dominio: Dominio, indicador: string) {
|
||||
return this.http.get<unknown>(`/${requireDominio(dominio)}/indicadores/${encodeURIComponent(indicador)}/metadatos`).pipe(map(value => {
|
||||
if (!record(value)) throw new Error('Metadatos inválidos');
|
||||
const description = value['descripcion'];
|
||||
if (description !== undefined && description !== null && typeof description !== 'string') throw new Error('Metadatos inválidos');
|
||||
const ficha = value['ficha'];
|
||||
if (ficha !== undefined && ficha !== null) {
|
||||
if (!record(ficha)) throw new Error('Metadatos inválidos');
|
||||
for (const field of ['codigo', 'para', 'unidad', 'pregunta', 'definicion', 'nota']) {
|
||||
const content = ficha[field];
|
||||
if (content !== undefined && content !== null && typeof content !== 'string') throw new Error('Metadatos inválidos');
|
||||
}
|
||||
}
|
||||
for (const field of ['referencias', 'poblaciones']) {
|
||||
const list = value[field];
|
||||
if (list !== undefined && (!Array.isArray(list) || !list.every(v => record(v) && (field === 'referencias'
|
||||
if (list !== undefined && list !== null && (!Array.isArray(list) || !list.every(v => record(v) && (field === 'referencias'
|
||||
? typeof v['tipo'] === 'string' && typeof v['etiqueta'] === 'string' && (v['ref'] === null || typeof v['ref'] === 'string')
|
||||
: typeof v['grupo'] === 'string' && typeof v['codigo'] === 'string' && typeof v['descripcion'] === 'string')))) throw new Error('Metadatos inválidos');
|
||||
}
|
||||
const figureDetails = value['figuras_detalle'];
|
||||
if (figureDetails !== undefined && figureDetails !== null && (!Array.isArray(figureDetails) || !figureDetails.every(v => record(v)
|
||||
&& typeof v['figura'] === 'string' && v['figura'].trim().length > 0
|
||||
&& (v['descripcion'] === null || typeof v['descripcion'] === 'string')
|
||||
&& (v['como_leer'] === null || Array.isArray(v['como_leer']) && v['como_leer'].every(line => typeof line === 'string'))))) {
|
||||
throw new Error('Metadatos inválidos');
|
||||
}
|
||||
if (Array.isArray(figureDetails) && new Set(figureDetails.map(item => (item as Record<string, unknown>)['figura'])).size !== figureDetails.length) {
|
||||
throw new Error('Metadatos inválidos');
|
||||
}
|
||||
return value as IndicadorMetadatos;
|
||||
}));
|
||||
}
|
||||
@@ -49,7 +69,7 @@ export class IndicadoresService {
|
||||
if (!['grupo_edad', 'estatus_seguimiento'].includes(scope.estrato)) throw new Error('Dimensión no admitida');
|
||||
params = params.set('estrato', scope.estrato);
|
||||
}
|
||||
for (const filtro of scope.filtros ?? []) params = params.append('filtro', filtro);
|
||||
if (scope.filtros?.length) params = params.set('filtro', scope.filtros.join(','));
|
||||
if (periodos) params = params.set('periodos', [...new Set(periodos)].join(','));
|
||||
return this.http.get<unknown>(`/${domain}/indicadores/${encodeURIComponent(indicador)}/datos`, { params }).pipe(map(value => {
|
||||
if (!record(value) || value['id'] !== indicador || typeof value['contrato'] !== 'string'
|
||||
|
||||
Reference in New Issue
Block a user