Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥝 Procesar colectivos, css, páginas varias #12

Merged
merged 10 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
30 changes: 27 additions & 3 deletions aplicaciones/procesador/fuente/ayudas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { writeFileSync } from 'fs';
import colores from 'cli-color';
import { emojify } from 'node-emoji';
import { ElementoLista } from 'tipos';
import slugificar from 'slug';

export const logError = colores.red.bold;
export const logAviso = colores.bold.xterm(214);
Expand All @@ -19,6 +21,28 @@ export const guardarJSON = (json: any, nombre: string) => {
writeFileSync(`../www/estaticos/datos/${nombre}.json`, JSON.stringify(json));
};

export function procesarLista(valor: string, lista: ElementoLista[]) {
if (!valor) return;
const slug = valor ? slugificar(`${valor}`) : '';
const existe = lista.find((obj) => obj.slug === slug);
if (!valor || valor === 'No aplica' || valor === 'undefined' || valor === 'Sin Información' || valor === '(s.f)')
return;
const nombre = `${valor}`.trim();

if (!existe) {
const objeto: ElementoLista = {
nombre: nombre,
conteo: 1,
slug: slug,
relaciones: [],
publicaciones: [],
};
lista.push(objeto);
} else {
existe.conteo++;
}
}

export function ordenarListaObjetos(lista: any[], llave: string, descendente = false) {
lista.sort((a, b) => {
if (a[llave] < b[llave]) return descendente ? -1 : 1;
Expand All @@ -28,10 +52,10 @@ export function ordenarListaObjetos(lista: any[], llave: string, descendente = f
}

export const normalizar = (texto: string): string => {
return texto
.toLocaleLowerCase()
return texto;
/* .toLocaleLowerCase()
.normalize('NFD')
.replace(/\p{Diacritic}/gu, '');
.replace(/[\u0300-\u036f]/g, ''); */
};

export const enMinusculas = (texto: string) => texto === texto.toLowerCase();
Expand Down
4 changes: 1 addition & 3 deletions aplicaciones/procesador/fuente/indicadores.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { guardarJSON } from './ayudas';
import slugificar from 'slug';
import { Indicador, Subindicador } from 'tipos.js';
import { getXlsxStream } from 'xlstream';
Expand Down Expand Up @@ -35,7 +34,7 @@ export async function procesarIndicadores(archivo: string, hoja: string, lista:
id: +fila[0], // revisar si es número
nombre: nombre,
slug: slug,
descripcion: fila[2].trim(),
descripcion: fila[2] ? fila[2].trim() : 'no hay descripción',
};

lista.push(respuesta);
Expand Down Expand Up @@ -130,7 +129,6 @@ export async function procesarSubindicadores(

if (!filasPreprocesadas && totalFilas === filasProcesadas) {
filasPreprocesadas = true;
// construirRelacionesDePublicaciones();
}

resolver(lista);
Expand Down
Loading