Module: Statistics Update from CIA Database - Automated Metrics Synchronization

Automated statistics synchronization system updating riksdagsmonitor website with current parliamentary and historical statistics from CIA production database. Maintains accurate metrics for website index pages describing parliament size, politician tracking scope, and legislative activity volumes. Supports data-driven transparency and audience understanding of Swedish political system.

Operational Purpose: Synchronizes public statistics from CIA production database to all 14 language variants of riksdagsmonitor website (index.html, index_sv.html, ..., index_zh.html). Ensures website accurately reflects current parliamentary composition and tracking scope. Automates what would otherwise require manual updates across 14 files.

Statistics Categories Maintained:

  • Current MP Count: 349 (standard Swedish Riksdag size)
  • Historical Politicians: 2,494 (all politicians since 1971, ~50+ years)
  • Riksdag Establishment: 1971 (founding of modern parliament)
  • Coverage Scope: All legislative sessions and government activities
  • Tracked Parties: 8 major parties plus historic parties
  • Committee System: 15-16 standing committees

Data Strategy: The system distinguishes between two key metrics:

  • current_mps = 349: Active members in current Riksdag session
  • person_data = 2,494: Total unique politicians tracked historically

This dual approach answers two audience questions: "How many MPs are currently in parliament?" → 349 (current composition) "How much parliamentary history do you track?" → 2,494+ politicians (temporal scope)

Website Pages Updated (14 language variants):

  • index.html: English version
  • index_sv.html: Swedish version
  • index_da.html: Danish version
  • index_no.html: Norwegian version
  • index_fi.html: Finnish version
  • index_de.html: German version
  • index_fr.html: French version
  • index_es.html: Spanish version
  • index_nl.html: Dutch version
  • index_ar.html: Arabic version
  • index_he.html: Hebrew version
  • index_ja.html: Japanese version
  • index_ko.html: Korean version
  • index_zh.html: Chinese version

Data Source:

  • CIA Production Database: Official Swedish parliament intelligence system
  • Data Path: ./cia-data/production-stats.json
  • Update Frequency: Typically daily from CIA production environment
  • Data Integrity: Validated against official parliament records

Statistics Update Methodology:

  1. Load production statistics from CIA data JSON file
  2. For each website index file:
    • Read current HTML content
    • Locate statistics placeholders (e.g., )
    • Replace with current values from production database
    • Update descriptive text with scope explanation
    • Preserve all other HTML structure
  3. Write updated files back to filesystem
  4. Log changes and generate summary report

Statistics Presentation: Website descriptions follow this pattern: "Monitor [NUMBER] current Members of Parliament (MPs) from [NUMBER]+ historical politicians tracked across [SCOPE] in the Swedish Riksdag and government system."

Example English: "Monitor 349 current Members of Parliament (MPs) from 2,494+ historical politicians tracked across 50+ years in the Swedish Riksdag and government system."

The format explains:

  • 349: Current active MPs (relevant to today's coverage)
  • 2,494+: Historical tracking scope (demonstrates data comprehensiveness)
  • 50+ years: Temporal range of parliament tracking

Integration Points:

  • CI/CD Pipeline: Runs after news generation and schema synchronization
  • Homepage Display: Statistics on landing page (all languages)
  • SEO Metadata: Statistics in page meta descriptions
  • Analytics: Tracks audience engagement with parliament data
  • Data Dictionary: Documents what statistics are tracked

Change Detection & Reporting:

  • Tracks which files were actually modified
  • Reports statistics before/after for audit trail
  • Logs only files with substantive changes (avoids churn)
  • Provides summary of update scope

Error Handling:

  • Validates production-stats.json format
  • Gracefully handles missing statistics (uses defaults)
  • Validates HTML file structure before updates
  • Reports files that couldn't be processed
  • Maintains backup of original files if needed

ISMS Compliance - Data Integrity & Source Attribution:

  • ISO 27001:2022 A.5.33 - Protection of records Ensures statistics maintain proper source attribution to CIA database Documented chain of custody from CIA production to website

  • ISO 27001:2022 A.8.3 - Information lifecycle management Automated update process maintains current information Deprecates stale statistics automatically via synchronization

  • ISO 27001:2022 A.8.10 - Information deletion When parliament composition changes, old statistics properly retained in version history Enables historical analysis and trend tracking

  • NIST CSF 2.0 PR.DS-5 - Data integrity Validation checks ensure statistics match source database Change logs provide audit trail of modifications

  • CIS Control 3.14 - Data integrity validation Automated verification that website statistics match database source Prevents manual transcription errors

Data Protection Considerations:

  • Processes only public government data (Offentlighetsprincipen)
  • Journalists/OSINT platform covering public officials in official capacity
  • Statistics aggregated (no individual politician data exposed)
  • Complies with GDPR Article 6(1)(e) - Public interest processing
  • No personal data processing (statistical aggregates only)

Search Engine Optimization:

  • Meta descriptions include current statistics for search results
  • Open Graph tags include statistics for social media previews
  • Schema.org markup documents organization metrics
  • Improves click-through rates for searches about Swedish parliament

Performance Characteristics:

  • Loads production-stats.json: < 10ms
  • Per-file update: 2-5ms (regex replacement)
  • 14 files × 5ms = ~70ms total execution
  • Negligible performance impact on build pipeline

Usage: node scripts/update-stats-from-cia.js

Updates all 14 index files with current statistics

Logs changes and generates summary report

Environmental Setup:

  • CIA data file: ./cia-data/production-stats.json (required)
  • Index files: ./index.html through ./index_zh.html (required)
  • File permissions: Read/write access to index files
  • No external dependencies beyond Node.js

Troubleshooting:

  • No CIA data file: Check production-stats.json exists and is valid JSON
  • Index files not found: Verify website root directory structure
  • Statistics not updating: Check file write permissions
  • Wrong statistics: Verify CIA database is current

Future Enhancements:

  • Support for additional statistics (committee counts, bill volumes, etc.)
  • Multi-level statistics (party breakdown, committee composition)
  • Historical statistics tracking for trend analysis
  • Real-time API endpoint for statistics (vs. static files)
Version:
  • 1.6.0
Author:
  • Hack23 AB (Intelligence Metrics Team)
License:
  • Apache-2.0
Source:
See:
  • CIA Production Database (upstream data source)
  • GDPR Article 6(1)(e) - Public interest processing
  • ISO 27001:2022 A.5.33 - Protection of records
  • Offentlighetsprincipen (Swedish public access principle)

Methods

(inner) loadStats() → {Object}

Load production statistics

Source:
Returns:

Statistics data

Type
Object

(async, inner) main()

Main execution

Source:

(inner) updateHTMLFile(filePath, stats) → {Object}

Update HTML file with new statistics

Parameters:
Name Type Description
filePath string

Path to HTML file

stats Object

Statistics data

Source:
Returns:

Update summary

Type
Object