+page.js
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export const ssr = false;
export async function load({ fetch }) {
const [pobRes, ubigeoRes] = await Promise.all([
fetch('/poblacion.csv').then(r => r.text()),
fetch('/api/ubigeo-todo?gestion=2025').then(r => r.json())
]);
const poblacionMap = {};
pobRes.split('\n').slice(1).forEach(line => {
const [cod, , gestion, pob] = line.split(',');
if (parseInt(gestion) === 2025) {
poblacionMap[cod] = parseInt(pob);
}
});
const resumen = (ubigeoRes || [])
.filter(d => d.ubigeo !== '0.0.0' && !d.ubigeo.endsWith('.0') && !/multimunicipal/i.test(d.desc_ubigeo) && !/multiprovincial/i.test(d.desc_ubigeo) && !/desconocido/i.test(d.desc_ubigeo))
.map(d => ({
codigo: d.ubigeo,
desc: d.desc_ubigeo,
gestion: d.gestion,
devengado: d.monto,
ranking: d.ranking,
per_capita: d.per_capita,
departamento: d.desc_departamento
}));
const gestiones = [2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025];
return {
resumen,
poblacionMap,
gestiones,
gestionInicial: 2025
};
}