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

🖌️ Graficar Caracterización de Encuentros #51

Merged
merged 19 commits into from
Dec 17, 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
45 changes: 17 additions & 28 deletions aplicaciones/procesador/fuente/procesadorCaracterizacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function procesarLista(llaveLista: LlavesCaracterizacion, valor: string) {
existe.conteo++;
}

return { nombre, slug };
return { nombre, slug, conteo: existe?.conteo || 1 };
}

export default async (
Expand Down Expand Up @@ -65,67 +65,56 @@ export default async (
* Sedes: cantidad de participantes por sede por encuentro
*/
if (fila[3]) {
const nombreSede = slugificar(limpiarTextoSimple(fila[3]));
const { nombre, slug, conteo } = procesarLista('sedes', fila[3]);

const existeSede: { slug: string; conteo: number } | undefined = encuentro.sedes?.find((sede) => {
return sede.slug === nombreSede;
});
const existeSede = encuentro.sedes?.find((sede) => sede.slug === slug);

if (!existeSede) {
encuentro.sedes?.push({ slug: nombreSede, conteo: 1 });
encuentro.sedes?.push({ nombre, slug, conteo });
} else {
existeSede.conteo++;
existeSede.conteo = conteo;
}
}

/**
* Tipos Sedes: cantidad de participantes por tipo de sede por encuentro
*/
if (fila[4]) {
const tipoSede = slugificar(limpiarTextoSimple(fila[4]));

const existeTipo: { slug: string; conteo: number } | undefined = encuentro.tiposSede?.find((tipo) => {
return tipo.slug === tipoSede;
});
const { nombre, slug, conteo } = procesarLista('tipos', fila[4]);
const existeTipo = encuentro.tiposSede?.find((tipo) => tipo.slug === slug);

if (!existeTipo) {
encuentro.tiposSede?.push({ slug: tipoSede, conteo: 1 });
encuentro.tiposSede?.push({ nombre, slug, conteo });
} else {
existeTipo.conteo++;
existeTipo.conteo = conteo;
}
}

/**
* Roles: cantidad de participantes por rol por encuentro
*/
if (fila[5]) {
const nombreRol = slugificar(limpiarTextoSimple(fila[5]));

const existeRol: { slug: string; conteo: number } | undefined = encuentro.roles?.find((rol) => {
return rol.slug === nombreRol;
});
const { nombre, slug, conteo } = procesarLista('roles', fila[5]);
const existeRol = encuentro.roles?.find((rol) => rol.slug === slug);

if (!existeRol) {
encuentro.roles?.push({ slug: nombreRol, conteo: 1 });
encuentro.roles?.push({ nombre, slug, conteo });
} else {
existeRol.conteo++;
existeRol.conteo = conteo;
}
}

/**
* Cargos/Áreas: cantidad de participantes por cargo o área por encuentro
*/
if (fila[6]) {
const nombreCargo = slugificar(limpiarTextoSimple(fila[6]));

const existeCargo: { slug: string; conteo: number } | undefined = encuentro.cargos?.find((cargo) => {
return cargo.slug === nombreCargo;
});
const { nombre, slug, conteo } = procesarLista('cargos', fila[6]);
const existeCargo = encuentro.cargos?.find((cargo) => cargo.slug === slug);

if (!existeCargo) {
encuentro.cargos?.push({ slug: nombreCargo, conteo: 1 });
encuentro.cargos?.push({ nombre, slug, conteo });
} else {
existeCargo.conteo++;
existeCargo.conteo = conteo;
}
}
}
Expand Down
37 changes: 31 additions & 6 deletions aplicaciones/procesador/fuente/procesadorCaracterizacionListas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { Errata, FilaCaracterizacion, FilaColectivos } from './tipos';
const encuentrosCaracterizacion: EncuentroCaracterizacion[] = [];
const listas: ListasCaracterizacion = {
sedes: [],
tiposSede: [],
tipos: [],
roles: [],
cargos: [],
};
Expand Down Expand Up @@ -100,7 +100,7 @@ export default async (
const { nombre, slug } = procesarLista('sedes', valorTipoSede);
tiposSede.push({ nombre, slug });

encuentro.tiposSede = tiposSede;
encuentro.tipos = tiposSede;
} else {
errata.push({ fila: numeroFila, error: `No tiene SEDE.` });
}
Expand Down Expand Up @@ -130,7 +130,6 @@ export default async (
}

encuentrosCaracterizacion.push(encuentro);
console.log(encuentro);
}

numeroFila++;
Expand Down Expand Up @@ -161,7 +160,7 @@ export default async (

function construirRelacionesEncuentros() {
// Estos campos son los que se usan para crear relaciones
const campos: LlavesCaracterizacion[] = ['sedes', 'tiposSede', 'roles', 'cargos'];
const campos: LlavesCaracterizacion[] = ['sedes', 'tipos', 'roles', 'cargos'];

encuentrosCaracterizacion.forEach((encuentro) => {
// Pasar por cada campo sobre los que queremos construir relaciones
Expand Down Expand Up @@ -210,6 +209,32 @@ export default async (
}

function llenarRelacion(
slugsHacia: string[],
lista: ElementoLista[],
idDesde: string,
tipoRelacion: LlavesCaracterizacion,
idCaracterizacion: string
) {
slugsHacia.forEach((slugHacia) => {
const elementoALlenar = lista.find((obj) => obj.slug === slugHacia);

if (elementoALlenar) {
const existe = elementoALlenar.relaciones.find((obj) => obj.id === idDesde && obj.tipo === tipoRelacion);

if (!existe) {
elementoALlenar.relaciones.push({ conteo: 1, id: idDesde, tipo: tipoRelacion });
} else {
existe.conteo++;
}

if (!elementoALlenar.encuentrosCaracterizacion?.includes(idCaracterizacion)) {
elementoALlenar.encuentrosCaracterizacion?.push(idCaracterizacion);
}
}
});
}

/* function llenarRelacion(
elementosDondeConectar: string[],
elementoLista: ElementoLista[],
indice: string,
Expand All @@ -224,7 +249,7 @@ export default async (
const existe = elementoALlenar.relaciones.find((obj) => obj.id === indice);

if (!existe) {
elementoALlenar.relaciones.push({ conteo: 1, id: indice, nombre: nombre, tipo: campoRelacion });
elementoALlenar.relaciones.push({ conteo: 1, id: indice, tipo: campoRelacion });
} else {
existe.conteo++;
}
Expand All @@ -236,5 +261,5 @@ export default async (

// console.log('poner', campoRelacion, 'como relacion en lista', elementoConector);
});
}
} */
};
2 changes: 1 addition & 1 deletion aplicaciones/www/estaticos/datos/encuentros.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion aplicaciones/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<meta
name="viewport"
content="height=device-height,
width=device-width, initial-scale=1.0,
minimum-scale=1.0, maximum-scale=1.0,
user-scalable=no"
/>
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
Expand Down
7 changes: 3 additions & 4 deletions aplicaciones/www/src/Aplicacion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ onUnmounted(() => {
<div :onclick="abrirCerrarMenu" class="icono"><img src="/icono_cuenco.webp" /></div>
<nav id="menu" ref="menu" :class="abierto ? 'abierto' : ''">
<RouterLink class="elementoMenu" to="/">Inicio</RouterLink>
<RouterLink class="elementoMenu" :class="paginaActual === 'colectivos' ? 'activo' : ''" to="/colectivos/mapa">
Colectivos y Ámbitos
</RouterLink>
<RouterLink class="elementoMenu" to="/colectivos/mapa"> Colectivos y Ámbitos </RouterLink>
<RouterLink class="elementoMenu" to="/publicaciones">Producción Académica</RouterLink>
<RouterLink class="elementoMenu" to="/encuentros">Encuentros</RouterLink>
<RouterLink class="elementoMenu" to="/creditos">Créditos</RouterLink>
Expand All @@ -68,7 +66,8 @@ onUnmounted(() => {
position: fixed;
top: 0;
z-index: 9;
width: 100vw;
width: 90vw;
background-color: var(--blanco);
}

.icono {
Expand Down
48 changes: 48 additions & 0 deletions aplicaciones/www/src/cerebros/datos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import type {
LlavesColectivos,
LlavesPublicaciones,
Publicacion,
ListasCaracterizacion,
LlavesCaracterizacion,
EncuentroCaracterizacionConteo,
} from '@/tipos/compartidos';

export const usarCerebroDatos = defineStore('cerebroDatos', {
Expand Down Expand Up @@ -36,6 +39,13 @@ export const usarCerebroDatos = defineStore('cerebroDatos', {
listasPublicaciones: null,
listasPublicacionesOrdenadas: null,
cargandoListasPublicaciones: false,

// CARACTERIZACIÓN ENCUENTROS
encuentrosCaracterizacionConteo: null,
cargandoEncuentroCaracterizacion: false,

listasCaracterizacion: null,
cargandoCaracterizacionConteo: false,
};
},

Expand Down Expand Up @@ -164,5 +174,43 @@ export const usarCerebroDatos = defineStore('cerebroDatos', {
console.error('Problema cargando datos de listasColectivos', JSON.stringify(error));
}
},

// CARACTERIZACIÓN DE ENCUENTROS
async cargarDatosCaracterizacion() {
if (this.encuentrosCaracterizacionConteo || this.cargandoEncuentroCaracterizacion) return;
this.cargandoEncuentroCaracterizacion = true;

try {
this.encuentrosCaracterizacionConteo =
await pedirDatos<EncuentroCaracterizacionConteo[]>('datos/encuentros.json');
this.cargandoEncuentroCaracterizacion = false;
} catch (error) {
console.error('Problema cargando datos de encuentros', JSON.stringify(error));
}

await this.cargarListasCaracterizacion();
},

async cargarListasCaracterizacion() {
if (this.listasCaracterizacion || this.cargandoCaracterizacionConteo) return;
this.cargandoCaracterizacionConteo = true;

try {
const listas = await pedirDatos<ListasCaracterizacion>('datos/listasEncuentros.json');
this.listasCaracterizacion = { sedes: [], tiposSede: [], roles: [], cargos: [] };

for (const tipo in listas) {
const lista = [...listas[tipo as LlavesCaracterizacion]];
const largo = lista.length;
ordenarRapido(lista, 0, largo - 1, largo);
if (!this.listasCaracterizacion) return;
this.listasCaracterizacion[tipo as LlavesCaracterizacion] = lista;
}
this.listasCaracterizacion = listas;
this.cargandoListasColectivos = false;
} catch (error) {
console.error('Problema cargando datos de caracterizacionConteo', JSON.stringify(error));
}
},
},
});
1 change: 1 addition & 0 deletions aplicaciones/www/src/cerebros/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const usarCerebroGeneral = defineStore('cerebroGeneral', {
return {
paginaActual: 'inicio',
vistaColectivos: 'mapa',
fragmentoDonaElegido: '',
};
},
});
4 changes: 4 additions & 0 deletions aplicaciones/www/src/componentes/Buscador.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ async function abrirElemento(evento: MouseEvent, resultado: OpcionBuscadorDatos)
height: $altoMenuPantalla - 30px;
margin: 10px 0 0 0;
z-index: 9;
border-radius: 50%;
width: 30px;
padding-left: 1px;
}

#botonBuscador {
Expand All @@ -172,6 +175,7 @@ async function abrirElemento(evento: MouseEvent, resultado: OpcionBuscadorDatos)
filter: invert(1);
z-index: 2;
padding: 0 0.3em;
margin-right: 7px;
}

#buscador {
Expand Down
Loading
Loading