INNER CODE UNIT · Python
api_aois
marc-shade/world-intel-mcp · src/world_intel_mcp/dashboard/app.py:541
async def api_aois(request):
"""User-defined AOI geofences for the map layer, each with what the
last collector sweep counted inside it.
Reads the stored change snapshot rather than gathering live: drawing
a shape must never cost the 60-90 s of upstream fetches a brief
does. An AOI that has never been swept reports ``last_sweep: null``
rather than a row of zeros, and a broken store is a 503 with the
reason, never an empty list that reads as "no areas defined".
"""
cors = {"Access-Control-Allow-Origin": "*"}
try:
store = _open_aoi_store()
try:
aois = []
for row in store.list_all():
snap = store.get_snapshot(row["name"])
last_sweep = None