Skip to content

Commit

Permalink
👷 Procesar subindicadores en publicaciones
Browse files Browse the repository at this point in the history
  • Loading branch information
anattolia committed Aug 13, 2024
1 parent cc93ed5 commit d3acbbe
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 28 deletions.
66 changes: 46 additions & 20 deletions aplicaciones/procesador/fuente/procesador.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ const campos: Campos = [
{ llave: 'tipos', indice: 4 },
{ llave: 'dependencias', indice: 8 },
{ llave: 'indicadores', indice: 9 },
//{ llave: 'subindicadores', indice: 10 },
{ llave: 'subindicadores', indice: 10 },
];

const publicaciones: Publicacion[] = [];
const indicadoresPA: Indicador[] = [];
const SubindicadoresPA: Subindicador[] = [];
let indicadoresProcesados: Indicador[] = [];
let subindicadoresProcesados: Subindicador[] = [];

const listas: Listas = {
autores: [],
años: [],
tipos: [],
dependencias: [],
indicadores: [],
subindicadores: [],
};

async function procesarProduccion(): Promise<void> {
Expand Down Expand Up @@ -98,6 +100,7 @@ async function procesarProduccion(): Promise<void> {
procesarLista(dependencia, listas.dependencias);
procesarLista(tipos, listas.tipos);
procesarLista(`${años}`, listas.años);
procesarLista(subindicador, listas.subindicadores);
procesarListaIndicadores(indicador);

for (let fila in autores) {
Expand Down Expand Up @@ -135,7 +138,20 @@ async function procesarProduccion(): Promise<void> {
function procesarFila(fila: string[], numeroFila: number) {
const tituloPublicacion = fila[5].trim();
const autores = fila[1]?.includes(';') ? separarPartes(fila[1], ';') : [fila[1]?.trim()];
const subindicador = fila[10] ? fila[10].trim() : 'undefined';
const subindicador = fila[10]?.trim();

if (!subindicador) {
console.log(`No hay subindicador en ${numeroFila}`);
return;
}

const subindicadorProcesado = subindicadoresProcesados.find((obj) => {
return obj.slug === slugificar(subindicador);
});

if (!subindicadorProcesado) {
console.log(`No existe el subindicador ${subindicador} en la lista de subindicadores procesados`);
}

// Convertir autores en tipo DefinicionSimple
const autoresProcesados = autores.map((autor) => {
Expand All @@ -146,6 +162,8 @@ function procesarFila(fila: string[], numeroFila: number) {
return slugificar(fila[9].trim()) === obj.slug;
});

// En la tabla todas las publicaciones parecen tener subindicador pero muchos son el mismo indicador repetido.
// Aquí estoy borrando el campo subindicador si es el mismo indicador y no un subindicador
const respuesta: Publicacion = {
id: +fila[0],
titulo: { nombre: tituloPublicacion, slug: slugificar(tituloPublicacion) },
Expand All @@ -157,7 +175,14 @@ function procesarFila(fila: string[], numeroFila: number) {
fuente: fila[7],
dependencias: { nombre: fila[8].trim(), slug: slugificar(fila[8].trim()) },
indicadores: indicador,
//subindicadores: subindicador ? { nombre: subindicador, slug: slugificar(subindicador) } : undefined,
subindicadores: subindicadorProcesado
? {
id: subindicadorProcesado.id,
nombre: subindicadorProcesado.nombre,
slug: subindicadorProcesado.slug,
indicadorMadre: subindicadorProcesado.indicadorMadre,
}
: undefined,
};

// ¿Esto qué hace?
Expand Down Expand Up @@ -209,7 +234,6 @@ function procesarListaIndicadores(indicador: string) {
slug: slug,
relaciones: [],
publicaciones: [],
subindicadores: [],
};
listas.indicadores.push(objeto);
} else {
Expand Down Expand Up @@ -280,21 +304,23 @@ function construirRelacionesDePublicaciones() {
const elementoALlenar = listas[llaveDondeLlenar].find((obj) => obj.slug === elementoConector);

if (elementoALlenar) {
const existe = elementoALlenar.relaciones.find((obj) => obj.slug === slug);

if (!elementoALlenar.publicaciones?.includes(id)) {
elementoALlenar.publicaciones?.push(id);
}

if (!existe) {
elementoALlenar.relaciones.push({
conteo: 1,
indice: i,
tipo: llaveALlenar,
slug,
});
} else {
existe.conteo++;
if (elementoALlenar.relaciones) {
const existe = elementoALlenar.relaciones.find((obj) => obj.slug === slug);

if (!elementoALlenar.publicaciones?.includes(id)) {
elementoALlenar.publicaciones?.push(id);
}

if (!existe) {
elementoALlenar.relaciones.push({
conteo: 1,
indice: i,
tipo: llaveALlenar,
slug,
});
} else {
existe.conteo++;
}
}
}
});
Expand All @@ -314,7 +340,7 @@ function construirRelacionesDePublicaciones() {

async function inicio() {
indicadoresProcesados = await procesarIndicadores(archivoPA, hojaPA, indicadoresPA);
const subindicadoresProcesados = await procesarSubindicadores(
subindicadoresProcesados = await procesarSubindicadores(
archivoPA,
hojaSubindicadoresPA,
SubindicadoresPA,
Expand Down
9 changes: 5 additions & 4 deletions aplicaciones/procesador/fuente/tipos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export interface ElementoLista {
descripcion?: string;
slug: string;
conteo: number;
relaciones: { tipo: keyof Listas | string; conteo: number; indice: number; slug: string }[];
relaciones?: { tipo: keyof Listas | string; conteo: number; indice: number; slug: string }[];
publicaciones?: number[];
}

export interface ElementoListaIndicadores extends ElementoLista {
subindicadores: ElementoLista[];
//subindicadores: ElementoLista[];
}

export interface Indicador {
Expand All @@ -37,9 +37,10 @@ export type Listas = {
tipos: ElementoLista[];
dependencias: ElementoLista[];
indicadores: ElementoListaIndicadores[];
subindicadores: ElementoLista[];
};

export type LlavesProdAcademica = 'autores' | 'años' | 'tipos' | 'dependencias' | 'indicadores';
export type LlavesProdAcademica = 'autores' | 'años' | 'tipos' | 'dependencias' | 'indicadores' | 'subindicadores';

export type Campos = { llave: LlavesProdAcademica; indice: number }[];

Expand All @@ -54,5 +55,5 @@ export type Publicacion = {
fuente?: string;
dependencias?: DefinicionSimple;
indicadores?: Indicador;
subindicadores?: Indicador;
subindicadores?: Subindicador;
};
2 changes: 1 addition & 1 deletion aplicaciones/www/estaticos/datos/listas.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aplicaciones/www/estaticos/datos/publicaciones.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions notasCorrecciones.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
- Múnera, Leopoldo | Múnera Ruíz, Leopoldo
- Sáenz Obregón, Javier | Sáenz Obregón,Javier
- Vásquez, Johanna | Vásquez Velásquez, Johana | Vásquez Velásquez, Johanna

- AUTORES: Revisar ortografía de los nombres o nombre en general:

- Belmonte Carrasco, Lucia -> ¿Falta tilde?
Expand All @@ -42,7 +41,9 @@
- Suarez, Francy -> ¿Suarez sin tilde?
- Varela Torres,Jorge -> Falta espacio entre la ',' y el nombre
- Vélez, Castaño -> ¿Castaño es el nombre?

- INDICADORES:

- ¿"POLÍTICAS EDUCATIVAS" o "POLÍTICAS DE EDUCACIÓN"? -> En los campos de publicaciones y en el diccionario se usa uno y en "Contenidos P.A. otra. -> Unificar

### Preguntas
- En la tabla todas las publicaciones parecen tener subindicador. Sin embargo, muchos son el mismo indicador y no un subindicador. ¿Se puede vaciar ese campo si es el mismo indicador?

0 comments on commit d3acbbe

Please sign in to comment.