Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 2x 2x 5x 3x 2x 5x 3x 2x | /**
* @module CIA/Loaders/Demographics
* @category Intelligence Platform - Data Acquisition & Pipeline Management
*
* @description
* Builds the parliamentary demographics dashboard from CIA CSV exports.
* Joins gender and experience distributions for the 8 Riksdag parties.
*
* @author Hack23 AB - Data Pipeline Engineering
* @license Apache-2.0
* @since 2026
*/
import type {
DemographicsDashboard,
ExperienceEntry,
GenderEntry
} from '../types.js';
import type { LoadCSV } from '../csv-utils.js';
import { CSV_SOURCES, RIKSDAG_PARTIES } from '../sources.js';
/**
* Build `DemographicsDashboard` from CSV sources.
*
* @param loadCSV - CSV loader closure
* @returns Gender and experience distribution rows for Riksdag parties only
*/
export async function loadDemographics(loadCSV: LoadCSV): Promise<DemographicsDashboard> {
const [genderRows, experienceRows] = await Promise.all([
loadCSV(CSV_SOURCES.genderByParty.local),
loadCSV(CSV_SOURCES.experienceByParty.local)
]);
const genderByParty: GenderEntry[] = genderRows
.filter(r => RIKSDAG_PARTIES.includes(r.party as string))
.map(r => ({
party: r.party as string,
gender: r.gender as string,
count: (r.count as number) || 0
}));
const experienceByParty: ExperienceEntry[] = experienceRows
.filter(r => RIKSDAG_PARTIES.includes(r.party as string))
.map(r => ({
party: r.party as string,
experienceLevel: (r.experience_level as string) || '',
politicianCount: (r.politician_count as number) || 0
}));
return {
title: 'Parliamentary Demographics',
description: 'Gender and experience distribution from CIA database exports',
lastUpdated: new Date().toISOString(),
genderByParty,
experienceByParty,
_source: 'csv'
};
}
|