Web export (dashboard feed)¶
Build the dashboard's data feed: one compact JSON file per month plus a manifest.
The dashboard (see dashboard/) is a static site, so it cannot query a database. Instead the
pipeline publishes small files it can download once and cache:
1 2 3 | |
The feed is rebuilt in full from the master dataset every time (about a second), so late revisions to earlier months are always picked up. The build is all-or-nothing: it is validated first and written to a temporary folder, so a bad run can never leave a half-written or truncated feed behind.
File format, one row per offense::
1 2 3 4 5 | |
Masked rows (see MASKED_CATEGORIES and MASKED_OFFENSE_TERMS) have no street address and only a coarse location.
It also writes city.geojson, wards.geojson and neighborhoods.geojson (outlines with 2020 census population)
for maps.
Run from the command line to rebuild from the master dataset::
1 | |
WebExportError
¶
Bases: RuntimeError
The feed could not be built safely. Nothing on disk was changed.
Source code in src/geocrime_stl/utils/web_export.py
183 184 | |
build_web_feed(df=None, out_dir=None, *, force=False)
¶
Rebuild the dashboard feed from the master dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame | None
|
Cleaned crime rows for ALL months. If omitted, the master dataset is loaded from disk. |
None
|
out_dir
|
Path | str | None
|
Destination folder. Defaults to |
None
|
force
|
bool
|
Skip the plausibility checks (partial newest month, big drop in total rows). |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
The manifest that was written. |
Raises:
| Type | Description |
|---|---|
WebExportError
|
If the input is unusable or the result fails validation. The existing feed is left untouched in that case. |
Source code in src/geocrime_stl/utils/web_export.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |