krz/omaha-metro-blotter

Archive of police activity and ALPR surveillance across the Omaha metro. alpr archive omaha police surveillance

Commit 355b04066b

355b04066bb51197a0b64f28a452a266ed9777dd

parent: 951d842f0c

Unsigned ci/daily-pull: pending

cmc <hello@cleberg.net> · 2026-09-25 01:42 UTC

Load caseNumber and offenseType from Flock search audits (!10)

Adds case_number and offense_type to alpr_searches, with a migration for the existing archive. Rows already loaded get the values on the next ingest; imported_at is not touched.

Layout: unified · split

ingest.py +16 −3
@@ -403,11 +403,18 @@ def ingest_flock(conn, _since):
403403 for r in reader:
404404 rows.append((agency, r["id"], r["searchDate"],
405405 int(r["networkCount"]) if r["networkCount"] else None,
406 r["reason"].strip() or None, r["userId"], now))
406 r["reason"].strip() or None, r["userId"],
407 (r.get("caseNumber") or "").strip() or None,
408 (r.get("offenseType") or "").strip() or None, now))
409 # imported_at is left alone on conflict: the staleness alarm reads it.
407410 conn.executemany(
408 """INSERT OR IGNORE INTO alpr_searches
411 """INSERT INTO alpr_searches
409412 (agency, search_id, searched_at, network_count, reason, user_id,
410 imported_at) VALUES (?,?,?,?,?,?,?)""", rows)
413 case_number, offense_type, imported_at) VALUES (?,?,?,?,?,?,?,?,?)
414 ON CONFLICT (agency, search_id) DO UPDATE SET
415 case_number = COALESCE(excluded.case_number, case_number),
416 offense_type = COALESCE(excluded.offense_type, offense_type)""",
417 rows)
411418 return len(rows), 0
412419
413420
@@ -439,6 +446,12 @@ def ingest_alpr(conn, _since):
439446def migrate(conn):
440447 """Add columns introduced after a database was first built. Runs before
441448 schema.sql so its views and indexes can reference the new columns."""
449 searches = {r[1] for r in conn.execute("PRAGMA table_info(alpr_searches)")}
450 if searches and "case_number" not in searches:
451 conn.execute("ALTER TABLE alpr_searches ADD COLUMN case_number TEXT")
452 conn.execute("ALTER TABLE alpr_searches ADD COLUMN offense_type TEXT")
453 conn.commit()
454
442455 have = {r[1] for r in conn.execute("PRAGMA table_info(incidents)")}
443456 if not have:
444457 return
schema.sql +2
@@ -101,6 +101,8 @@ CREATE TABLE IF NOT EXISTS alpr_searches (
101101 network_count INTEGER, -- camera networks the search reached across
102102 reason TEXT, -- free text, blank on most searches
103103 user_id TEXT, -- redacted upstream
104 case_number TEXT, -- absent from exports before 2026-09
105 offense_type TEXT, -- absent from exports before 2026-09
104106 imported_at TEXT NOT NULL,
105107 PRIMARY KEY (agency, search_id)
106108);