lgtm
This commit is contained in:
parent
2efa4d9f47
commit
5e73287eaf
99 changed files with 6392 additions and 1462 deletions
|
|
@ -334,6 +334,18 @@ struct Cli {
|
|||
#[arg(long, env = "CRIME_BY_YEAR_PATH")]
|
||||
crime_by_year_path: PathBuf,
|
||||
|
||||
/// Path to the per-incident crime-records parquet (last 7 years, postcode-
|
||||
/// sorted) backing the "individual crimes" list. Spilled to disk when
|
||||
/// `--spill-dir` is set.
|
||||
#[arg(long, env = "CRIME_RECORDS_PATH")]
|
||||
crime_records_path: PathBuf,
|
||||
|
||||
/// Path to the precomputed national/per-outcode/per-sector crime-averages
|
||||
/// parquet (built by pipeline.transform.area_crime_averages). The right pane
|
||||
/// uses it to compare a selection's crime rates against its surroundings.
|
||||
#[arg(long, env = "AREA_CRIME_AVERAGES_PATH")]
|
||||
area_crime_averages_path: PathBuf,
|
||||
|
||||
/// Path to the per-unit-postcode population parquet (ONS Census 2021 usual
|
||||
/// residents; display-only side table for the right pane). Optional: when
|
||||
/// absent or missing, the area pane simply omits the population figure.
|
||||
|
|
@ -725,6 +737,16 @@ async fn main() -> anyhow::Result<()> {
|
|||
Arc::new(data)
|
||||
};
|
||||
|
||||
let crime_records = {
|
||||
let path = &cli.crime_records_path;
|
||||
if !path.exists() {
|
||||
bail!("Crime-records parquet not found: {}", path.display());
|
||||
}
|
||||
let data = data::CrimeRecords::load(path, spill_dir)?;
|
||||
trim_allocator("crime-records load");
|
||||
Arc::new(data)
|
||||
};
|
||||
|
||||
let population = match &cli.population_path {
|
||||
Some(path) if path.exists() => {
|
||||
let data = data::PostcodePopulation::load(path)?;
|
||||
|
|
@ -742,13 +764,11 @@ async fn main() -> anyhow::Result<()> {
|
|||
};
|
||||
|
||||
let area_crime_averages = {
|
||||
let data = property_data.compute_area_crime_averages();
|
||||
info!(
|
||||
outcodes = data.by_outcode.len(),
|
||||
sectors = data.by_sector.len(),
|
||||
crime_types = data.crime_types.len(),
|
||||
"Per-outcode/sector crime averages computed"
|
||||
);
|
||||
let path = &cli.area_crime_averages_path;
|
||||
if !path.exists() {
|
||||
bail!("Area-crime-averages parquet not found: {}", path.display());
|
||||
}
|
||||
let data = data::AreaCrimeAverages::load(path)?;
|
||||
trim_allocator("area crime averages");
|
||||
Arc::new(data)
|
||||
};
|
||||
|
|
@ -781,6 +801,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
actual_listings,
|
||||
developments,
|
||||
crime_by_year,
|
||||
crime_records,
|
||||
population,
|
||||
area_crime_averages,
|
||||
token_cache,
|
||||
|
|
@ -899,6 +920,10 @@ async fn main() -> anyhow::Result<()> {
|
|||
"/api/postcode-properties",
|
||||
get(routes::get_postcode_properties).layer(ConcurrencyLimitLayer::new(10)),
|
||||
)
|
||||
.route(
|
||||
"/api/crime-records",
|
||||
get(routes::get_crime_records).layer(ConcurrencyLimitLayer::new(5)),
|
||||
)
|
||||
.route(
|
||||
"/api/screenshot",
|
||||
get(routes::get_screenshot).layer(ConcurrencyLimitLayer::new(3)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue