KSH statistics and raw datasets – import and storage
The indicator import, the file download, CSV and SDMX-ML processing, storage, the chart endpoints and the permission keys.
Overview
ksh/stat imports and charts NUTS3-level indicators, ksh/dataset browses the raw rows of downloaded datasets. Both resolve the active API configuration with code "ksh" (company → group → global).
Data model
Table names carry the installation's own prefix in the database.
| Table or location | Role | Key, main fields |
|---|---|---|
ksh_settlement_stat | indicator values | unique key (geo, year, indicator), value |
ksh_dataset_row | raw data rows | dataset, resource, geo, period, indicator, unit, value, row_json |
DIR_STORAGE/tmp_ksh/ | temporary download folder | CSV and XML files |
Process
stat.import: per thestat_indicatorslist (empty: the 2 built-in indicators) downloads each resource once (ksh->datasetData), filters to NUTS3, applies an optional column filter, normalises the number and upserts; on partial failure the errors are reported too.stat.fetchfiles: downloads the datasets ofraw_datasets(or onedatasetparameter) intotmp_ksh/(ksh->downloadDatasets).stat.processfiles:info=1lists the downloaded CSVs;file=batch-upserts one CSV into the raw table. The file name passesbasename, only.csv; the file is not deleted here.dataset.sync:info=1returns the (dataset, resource) pairs to process; for one resource: download, delete earlier rows (deleteByResource), process CSV or SDMX-ML XML with batched upserts, then delete the file.extis onlycsvorxml.- Charts:
stat.chartdataincountymode (latest year per county) ortrendmode (time series of one county);dataset.chartdatainautomode.
Permissions
ksh/stat:list(list and chart),import,delete,debug.ksh/dataset:list, with a content scope on geo codes (ksh_dataset/georules);import,delete,debug.dataset.clear(full truncation) is super admin only.
Background job
The direct entry point cron/kshfetch does the same download and processing as "Fetch & process"; it is not part of the central job queue, and no authentication check is visible in the controller.
Known limitations
- The
dataset.chartdataendpoint does not apply the geo-code content scope. - After
processfilesthe CSV stays in the download folder.