Skip to content

Commit

Permalink
Merge pull request #228 from enflujo/version-2
Browse files Browse the repository at this point in the history
🚀 Despliegue de Versión 2
  • Loading branch information
1cgonza authored Nov 14, 2024
2 parents ddaa8c3 + 0591086 commit efa4e9a
Show file tree
Hide file tree
Showing 338 changed files with 10,776 additions and 5,981 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
12 changes: 8 additions & 4 deletions .github/workflows/despliegue.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Despliegue
name: 🦍 Despliegue

on:
push:
Expand All @@ -11,18 +11,22 @@ jobs:

steps:
- name: 🐯 Obtener código del repositorio
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🐜 Activar Corepack
run: corepack enable

- name: 🐝 Usar Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'

- name: 🦒 Instalar dependencias y hacer build
run: |
yarn install --frozen-lockfile
yarn install --immutable
yarn build
- name: 🦅 Enviar por SFTP
uses: wangyucode/[email protected]
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/estilo-codigo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Estilo Código
name: 🐾 Estilo Código

on:
push:
Expand All @@ -14,18 +14,22 @@ jobs:

steps:
- name: 🐯 Obtener código del repositorio
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🐜 Activar Corepack
run: corepack enable

- name: 🐝 Usar Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'

- name: 🦒 Instalar dependencias
run: |
yarn install --frozen-lockfile
yarn install --immutable
- name: 👀 Buscar errores
run: yarn lint
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ dist
.DS_Store
publico
aplicaciones/procesador/fuente/datos/*
!aplicaciones/procesador/fuente/datos/README.md
!aplicaciones/procesador/fuente/datos/README.md

# Ver documentación de Yarn moderno (> v2): https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
publico
aplicaciones/www/estaticos/**/*
aplicaciones/www/src/datosVisibles/pesosArchivos.json
aplicaciones/procesador/fuente/indicadores/ya8_3_num.json
datosVisibles/pesosArchivos.json
aplicaciones/procesador/fuente/indicadores/ya8_3_num.json
.astro
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@
"printWidth": 120,
"tabWidth": 2,
"endOfLine": "auto",
"trailingComma": "es5"
"trailingComma": "es5",
"plugins": ["prettier-plugin-astro"],
"overrides": [
{
"files": "*.astro",
"options": {
"parser": "astro"
}
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsserver.experimental.useVsCodeWatcher": false
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
225 changes: 118 additions & 107 deletions aplicaciones/procesador/fuente/aplicacion.ts
Original file line number Diff line number Diff line change
@@ -1,133 +1,144 @@
import NumeradorDenominador from './modulos/NumeradorDenominador';
import VariableSingular from './modulos/VariableSingular';
import { departamentos, municipios } from './utilidades/lugaresColombia';
import { guardarJSON } from './utilidades/ayudas';
import { resolve } from 'path';
import { readdir, rm } from 'fs/promises';
import prerocesarIndicador83 from '@/indicadores/08-03';
import { rutaEstaticosDatos, rutaEstaticosDescarga } from './utilidades/constantes';
import calcularPesos from './datosDescarga';
import JuegoCategorias from './modulos/JuegoCategorias';
import VariableDoble from './modulos/VariableDoble';

async function inicio() {
// procesarLugares();
// await prerocesarIndicador83();
await vaciarProcesados();
await procesarDatos();
await vaciarCarpetaDescarga();
await calcularPesos();
}

async function vaciarProcesados() {
const rutaProcesados = resolve(__dirname, './datos/procesados');
const archivos = await readdir(rutaProcesados);
const respuesta = await readdir(rutaEstaticosDatos);

for (const archivo of archivos) {
await rm(`${rutaProcesados}/${archivo}`);
}
}

function procesarLugares() {
const deps = departamentos.datos.map((lugar) => {
return { nombre: lugar[1], codigo: lugar[0] };
});

guardarJSON(deps, 'buscador-deps');

const muns = municipios.datos.map((lugar): { nombre: string; codigo: string; dep?: string } => {
const departamento = departamentos.datos.find((dep) => dep[0] === lugar[2]);
if (!departamento) {
console.log(lugar);
throw new Error('no hay departamento');
}
return { nombre: `${lugar[1]} (${departamento[1]})`, codigo: lugar[3], dep: departamento[1] };
});
if (respuesta && respuesta.length) {
const archivos = respuesta.filter((nombre) => nombre.endsWith('.json'));

muns.sort((a, b) => {
if (a.dep && b.dep) {
if (a.dep > b.dep) return 1;
if (a.dep < b.dep) return -1;
for (const archivo of archivos) {
await rm(`${rutaEstaticosDatos}/${archivo}`);
}
return 0;
});
}
}

muns.forEach((mun) => {
delete mun.dep;
});
async function vaciarCarpetaDescarga() {
// Vaciar la carpeta de datos
const archivosXlsx = await readdir(rutaEstaticosDescarga);

guardarJSON(muns, 'buscador-muns');
for (const xlsx of archivosXlsx) {
await rm(`${rutaEstaticosDescarga}/${xlsx}`);
}
}

async function procesarDatos() {
/** 1 */
const ya11 = new VariableSingular('tacued', true, 'porcentaje');
await ya11.procesar('1.1: salud - acueducto', 'YA1_1.1', 'Sheet1', 'ya1-1');
await ya11.procesar('1.1: salud - acueducto', 'YA_1.1', 'Export', 'ya1-1');
const ya12 = new VariableSingular('talcan', true, 'porcentaje');
await ya12.procesar('1.2: salud - alcantarillado', 'YA1_1.2', 'Sheet1', 'ya1-2');
const ya13 = new VariableSingular('tasa_mortalidad_infantil', false, 'tasa', 100000);
await ya13.procesar('1.3: mortalidad menores', 'YA1_1.3', 'Sheet1', 'ya1-3');
const ya15 = new VariableSingular('controles_prenatales', true, 'porcentaje');
await ya15.procesar('1.5: controles prenatales', 'YA1_1.5', 'Sheet1', 'ya1-5');
const ya17 = new VariableSingular('desnutricion', false, 'tasa', 100000);
await ya17.procesar('1.7: desnutricion', 'YA1_1.7', 'Sheet1', 'ya1-7');
const ya18 = new VariableSingular('bajo_peso', false, 'porcentaje');
await ya18.procesar('1.8: bajo peso', 'YA1_1.8', 'Sheet1', 'ya1-8');

const ya21 = new VariableSingular('cobertura_bruta_transicion', true, 'porcentaje');
await ya21.procesar('2.1: cobertura transición', 'YA2_2.1', 'Sheet1', 'ya2-1');
await ya12.procesar('1.2: salud - alcantarillado', 'YA_1.2', 'Export', 'ya1-2');
const ya13 = new VariableSingular('tasa_mortalidad_menores_5', false, 'tasa');
await ya13.procesar('1.3: mortalidad menores', 'YA_1.3', 'Sheet 1', 'ya1-3');
const ya14 = new VariableSingular('controles_prenatales', true, 'porcentaje');
await ya14.procesar('1.4: controles prenatales', 'YA_1.4', 'Sheet 1', 'ya1-4');
const ya15 = new VariableSingular('tasa_desnutricion_menores_5', false, 'tasa', 100000);
await ya15.procesar('1.5: desnutrición', 'YA_1.5', 'Sheet 1', 'ya1-5');
const ya16 = new VariableSingular('bajo_peso', false, 'porcentaje');
await ya16.procesar('1.6: bajo peso', 'YA_1.6', 'Sheet 1', 'ya1-6');
const ya17 = new VariableSingular('tasa_mortalidad_neonatal', false, 'tasa', 1000);
await ya17.procesar('1.7: tasa mortalidad neonatal', 'YA_1.7', 'Sheet 1', 'ya1-7');
const ya18 = new VariableSingular('tasa_mortalidad_menores_1_año', false, 'tasa', 1000);
await ya18.procesar('1.8: tasa mortalidad menores 1 año', 'YA_1.8', 'Sheet 1', 'ya1-8');
const ya19 = new VariableSingular('tasa_mortalidad_desnutricion_5_años', false, 'tasa', 100000);
await ya19.procesar('1.9: tasa mortalidad desnutrición', 'YA_1.9', 'Sheet 1', 'ya1-9');
const ya10 = new VariableSingular('porcentaje_nacidos_vivos_personal_calificado', true, 'porcentaje');
await ya10.procesar('1.10: partos', 'YA_1.10', 'Sheet 1', 'ya1-10');

/** 2 */
const ya21 = new VariableSingular('neta_transicion', true, 'porcentaje');
await ya21.procesar('2.1: cobertura transición', 'YA_2.1', 'Sheet 1', 'ya2-1');
const ya22 = new VariableSingular('reprobacion_transicion', false, 'porcentaje');
await ya22.procesar('2.2: cobertura transición', 'YA2_2.2', 'Sheet1', 'ya2-2');
await ya22.procesar('2.2: cobertura transición', 'YA_2.2', 'Sheet 1', 'ya2-2');
const ya23 = new VariableSingular('repitencia_transicion', false, 'porcentaje');
await ya23.procesar('2.3: repitencia transición', 'YA2_2.3', 'Sheet1', 'ya2-3');
await ya23.procesar('2.3: repitencia transición', 'YA_2.3', 'Sheet 1', 'ya2-3');
const ya24 = new VariableSingular('desercion_transicion', false, 'porcentaje');
await ya24.procesar('2.4: deserción transición', 'YA2_2.4', 'Sheet1', 'ya2-4');

const ya31 = new VariableSingular('matematicas', true, 'porcentaje');
await ya31.procesar('3.1: saber 11 matemáticas', 'YA3_3.1', 'Sheet1', 'ya3-1');
const ya32 = new VariableSingular('lectura', true, 'porcentaje');
await ya32.procesar('3.2: saber 11 lectura', 'YA3_3.2', 'Sheet1', 'ya3-2');
const ya33 = new VariableSingular('total', true, 'porcentaje');
await ya33.procesar('3.3: saber 11 total', 'YA3_3.3', 'Sheet1', 'ya3-3');
const ya34 = new VariableSingular('cobertura_bruta_primaria', true, 'porcentaje');
await ya34.procesar('3.4: cobertura bruta primaria', 'YA3_3.4', 'Sheet1', 'ya3-4');
const ya35 = new VariableSingular('cobertura_bruta_secundaria', true, 'porcentaje');
await ya35.procesar('3.5: cobertura bruta secundaria', 'YA3_3.5', 'Sheet1', 'ya3-5');
const ya36 = new VariableSingular('cobertura_bruta_media', true, 'porcentaje');
await ya36.procesar('3.6: cobertura media', 'YA3_3.6', 'Sheet1', 'ya3-6');
const ya37 = new VariableSingular('reprobación_primaria', false, 'porcentaje');
await ya37.procesar('3.7: reprobación primaria', 'YA3_3.7', 'Sheet1', 'ya3-7');
const ya38 = new VariableSingular('reprobación_secundaria', false, 'porcentaje');
await ya38.procesar('3.8: reprobación secundaria', 'YA3_3.8', 'Sheet1', 'ya3-8');
const ya39 = new VariableSingular('reprobación_media', false, 'porcentaje');
await ya39.procesar('3.9: reprobación media', 'YA3_3.9', 'Sheet1', 'ya3-9');
const ya310 = new VariableSingular('repitencia_primaria', false, 'porcentaje');
await ya310.procesar('3.10: repitencia primaria', 'YA3_3.10', 'Sheet1', 'ya3-10');
const ya311 = new VariableSingular('repitencia_secundaria', false, 'porcentaje');
await ya311.procesar('3.11: repitencia secundaria', 'YA3_3.11', 'Sheet1', 'ya3-11');
const ya312 = new VariableSingular('repitencia_media', false, 'porcentaje');
await ya312.procesar('3.12: repitencia media', 'YA3_3.12', 'Sheet1', 'ya3-12');
const ya313 = new VariableSingular('desercion_primaria', false, 'porcentaje');
await ya313.procesar('3.13: deserción primaria', 'YA3_3.13', 'Sheet1', 'ya3-13');
const ya314 = new VariableSingular('desercion_secundaria', false, 'porcentaje');
await ya314.procesar('3.14: deserción secundaria', 'YA3_3.14', 'Sheet1', 'ya3-14');
const ya315 = new VariableSingular('desercion_media', false, 'porcentaje');
await ya315.procesar('3.15: deserción media', 'YA3_3.15', 'Sheet1', 'ya3-15');

const ya41 = new NumeradorDenominador(false, 'tasa', 100000);
await ya41.procesar('4.1: mortalidad EDA', 'YA4_4.1', 'datos', 'ya4-1');
const ya42 = new NumeradorDenominador(false, 'tasa', 100000);
await ya42.procesar('4.2: mortalidad IRA', 'YA4_4.2', 'datos', 'ya4-2');
await ya24.procesar('2.4: deserción transición', 'YA_2.4', 'Sheet 1', 'ya2-4');
const ya25 = new VariableSingular('porcentaje_marco_integral', true, 'porcentaje');
await ya25.procesar('2.5: porcentaje marco integral', 'YA_2.5', 'Sheet 1', 'ya2-5');
const ya26 = new VariableSingular('educ_inicial_icbf', true, 'conteo');
await ya26.procesar('2.6: educación inicial icbf', 'YA_2.6', 'Sheet 1', 'ya2-6');
const ya27 = new VariableDoble('#_estudiantes', true, 'conteo', 1);
await ya27.procesar('2.7: matriculados', 'YA_2.7', 'Sheet1', 'ya2-7');

/** 3 */
const ya31 = new VariableSingular('promedio_matematicas', true, 'promedio');
await ya31.procesar('3.1: saber 11 matemáticas', 'YA_3.1', 'Sheet 1', 'ya3-1');
const ya32 = new VariableSingular('promedio_lectura', true, 'promedio');
await ya32.procesar('3.2: saber 11 lectura', 'YA_3.2', 'Sheet 1', 'ya3-2');
const ya33 = new VariableSingular('promedio_sociales', true, 'promedio');
await ya33.procesar('3.3: saber 11 sociales', 'YA_3.3', 'Sheet 1', 'ya3-3');
const ya34 = new VariableSingular('promedio_puntaje_global', true, 'promedio');
await ya34.procesar('3.4: saber 11 global', 'YA_3.4', 'Sheet 1', 'ya3-4');
const ya35 = new VariableSingular('neta_primaria', true, 'porcentaje');
await ya35.procesar('3.5: cobertura bruta primaria', 'YA_3.5', 'Sheet 1', 'ya3-5');
const ya36 = new VariableSingular('neta_media', true, 'porcentaje');
await ya36.procesar('3.6: cobertura bruta secundaria', 'YA_3.6', 'Sheet 1', 'ya3-6');
const ya37 = new VariableSingular('reprobacion_primaria', false, 'porcentaje');
await ya37.procesar('3.7: reprobacion primaria', 'YA_3.7', 'Sheet 1', 'ya3-7');
const ya38 = new VariableSingular('reprobacion_media', false, 'porcentaje');
await ya38.procesar('3.8: reprobación media', 'YA_3.8', 'Sheet 1', 'ya3-8');
const ya39 = new VariableSingular('repitencia_primaria', false, 'porcentaje');
await ya39.procesar('3.9: repitencia primaria', 'YA_3.9', 'Sheet 1', 'ya3-9');
const ya310 = new VariableSingular('repitencia_media', false, 'porcentaje');
await ya310.procesar('3.10: repitencia media', 'YA_3.10', 'Sheet 1', 'ya3-10');
const ya311 = new VariableSingular('desercion_primaria', false, 'porcentaje');
await ya311.procesar('3.11: desercion primaria', 'YA_3.11', 'Sheet 1', 'ya3-11');
const ya312 = new VariableSingular('desercion_media', false, 'porcentaje');
await ya312.procesar('3.12: deserción media', 'YA_3.12', 'Sheet 1', 'ya3-12');

/** 4 */
const ya41 = new VariableSingular('tasa_EDA', false, 'tasa');
await ya41.procesar('4.1: mortalidad EDA', 'YA_4.1', 'Sheet 1', 'ya4-1');
const ya42 = new VariableSingular('tasa_IRA', false, 'tasa');
await ya42.procesar('4.2: mortalidad IRA', 'YA_4.2', 'Sheet 1', 'ya4-2');
const ya43 = new VariableSingular('tacued', true, 'porcentaje');
await ya43.procesar('4.3: acceso agua potable', 'YA4_4.3', 'Sheet1', 'ya4-3');
await ya43.procesar('4.3: acceso agua potable', 'YA_4.3', 'Export', 'ya4-3');
const ya44 = new VariableSingular('concentracion', false, 'escala');
await ya44.procesar('4.4: calidad aire', 'YA4_4.4', 'Sheet1', 'ya4-4');

const ya71 = new VariableSingular('GINI', false, 'coeficiente', 1.0);
await ya71.procesar('7.1: GINI', 'YA7_7.1', 'Sheet1', 'ya7-1');
const ya72 = new VariableSingular('pobreza', false, 'porcentaje');
await ya72.procesar('7.2: pobreza', 'YA7_7.2', 'Sheet1', 'ya7-2');

const ya81 = new VariableSingular('tasa', false, 'tasa', 100000);
await ya81.procesar('8.1: violencia física', 'YA8_8.1', 'Sheet1', 'ya8-1');
const ya83 = new VariableSingular('delito', false, 'tasa', 100000);
await ya83.procesar('8.3: delitos participación menores', 'YA8_8.3', 'Sheet1', 'ya8-3');
const ya84 = new VariableSingular('tasa', false, 'tasa', 100000);
await ya84.procesar('8.4: delito', 'YA8_8.4', 'Sheet1', 'ya8-4');

await ya44.procesar('4.4: calidad aire', 'YA_4.4', 'Sheet1', 'ya4-4');

/** 5 */
const ya51 = new JuegoCategorias('porcentaje', true, 'porcentaje');
ya51.procesar('5.1 juego', 'YA_5.1', 'Sheet 1', 'ya5-1');

/** 7 */
const ya71 = new VariableSingular('gini', false, 'coeficiente', 1.0);
await ya71.procesar('7.1: GINI', 'YA_7.1', 'Sheet1', 'ya7-1');
const ya72 = new VariableSingular('pobreza_monetaria', false, 'porcentaje');
await ya72.procesar('7.2: pobreza monetaria', 'YA_7.2', 'Sheet1', 'ya7-2');

/** 8 */
const ya81 = new VariableSingular('homicidios', false, 'tasa', 100000);
await ya81.procesar('8.1: homicidios', 'YA_8.1', 'Sheet 1', 'ya8-1');
const ya82 = new VariableSingular('sexual', false, 'tasa', 100000);
await ya82.procesar('8.2: violencia sexual', 'YA_8.2', 'Sheet 1', 'ya8-2');
const ya83 = new VariableSingular('intrafamiliar', false, 'tasa', 100000);
await ya83.procesar('8.3: violencia intrafamiliar', 'YA_8.3', 'Sheet 1', 'ya8-3');
const ya84 = new VariableSingular('interpersonal', false, 'tasa', 100000);
await ya84.procesar('8.4: violencia interpersonal', 'YA_8.4', 'Sheet 1', 'ya8-4');

/** 9 */
const ya91 = new VariableSingular('tasa', false, 'porcentaje');
await ya91.procesar('9.1: detención no privativa', 'YA_9.1', 'Sheet 1', 'ya9-1');
const ya92 = new VariableSingular('tasa', false, 'porcentaje');
await ya92.procesar('9.2: tiempo de reclutamiento', 'YA_9.2', 'Sheet 1', 'ya9-2');
const ya93 = new VariableSingular('tasa', false, 'porcentaje');
await ya93.procesar('9.3: justicia restaurativa', 'YA_9.3', 'Sheet 1', 'ya9-3');
const ya94 = new VariableSingular('tasa', false, 'porcentaje');
await ya94.procesar('9.4: acceso educativo', 'YA_9.4', 'Sheet 1', 'ya9-4');

/** 10 */
const ya101 = new VariableSingular('e_delito_sex', false, 'conteo', 1);
await ya101.procesar('10.1: delito sexual', 'YA10_10.1', 'Sheet1', 'ya10-1');
const ya102 = new VariableSingular('reclu', false, 'conteo', 1);
Expand All @@ -140,4 +151,4 @@ async function procesarDatos() {
await ya105.procesar('10.5: secuestro', 'YA10_10.5', 'Sheet1', 'ya10-5');
}

inicio();
inicio().catch(console.error);
Loading

0 comments on commit efa4e9a

Please sign in to comment.