feat(geofence): hear quakes, WFIGS incidents, and news pins
New hits carry a frozen evidence pack. adsb/ais/firms payloads stay unchanged, and cameras are never passed to record_and_notify.
This commit is contained in:
parent
d04ddc9afa
commit
d878655617
7 changed files with 990 additions and 26 deletions
31
app/main.py
31
app/main.py
|
|
@ -1788,24 +1788,31 @@ async def api_delete_geofence(gid: str):
|
|||
@app.get("/api/geofences/{gid}/at")
|
||||
async def api_geofence_at(
|
||||
gid: str,
|
||||
timestamp: str = Query(..., description="ISO-8601 instant for the 1-minute DVR bucket"),
|
||||
timestamp: str | None = Query(
|
||||
None, description="ISO-8601 instant for the 1-minute DVR bucket",
|
||||
),
|
||||
ts: str | None = Query(
|
||||
None,
|
||||
description="Alias of timestamp. Evidence snapshot URLs use this name.",
|
||||
),
|
||||
):
|
||||
"""Aircraft/vessels/fires inside this fence at time T. Never writes."""
|
||||
from geofence import snapshot_at
|
||||
from tracks import parse_timestamp
|
||||
|
||||
raw_ts = timestamp or ts
|
||||
try:
|
||||
ts = parse_timestamp(timestamp)
|
||||
ts_parsed = parse_timestamp(raw_ts)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(422, str(exc)) from exc
|
||||
if ts is None:
|
||||
if ts_parsed is None:
|
||||
raise HTTPException(422, "timestamp required")
|
||||
try:
|
||||
body = await snapshot_at(gid, ts)
|
||||
body = await snapshot_at(gid, ts_parsed)
|
||||
except Exception:
|
||||
body = {
|
||||
"geofence_id": gid,
|
||||
"timestamp": ts.isoformat(),
|
||||
"timestamp": ts_parsed.isoformat(),
|
||||
"aircraft": [],
|
||||
"vessels": [],
|
||||
"fires": [],
|
||||
|
|
@ -1820,15 +1827,23 @@ async def api_geofence_alerts(
|
|||
geofence_id: UUID | None = Query(None),
|
||||
since: str | None = Query(None, description="ISO-8601 inclusive lower bound"),
|
||||
until: str | None = Query(None, description="ISO-8601 inclusive upper bound"),
|
||||
source_kind: str | None = Query(None, description="firms|ais|adsb"),
|
||||
source_kind: str | None = Query(
|
||||
None,
|
||||
description="firms|ais|adsb|earthquake|fire_incident|news",
|
||||
),
|
||||
limit: int = Query(100, ge=1, le=500),
|
||||
):
|
||||
"""Hit log for drawn fences. Not /api/alerts (entity/keyword)."""
|
||||
from geofence import list_alerts
|
||||
from tracks import parse_timestamp
|
||||
|
||||
if source_kind is not None and source_kind not in ("firms", "ais", "adsb"):
|
||||
raise HTTPException(422, "source_kind must be one of: firms, ais, adsb")
|
||||
if source_kind is not None and source_kind not in (
|
||||
"firms", "ais", "adsb", "earthquake", "fire_incident", "news",
|
||||
):
|
||||
raise HTTPException(
|
||||
422,
|
||||
"source_kind must be one of: firms, ais, adsb, earthquake, fire_incident, news",
|
||||
)
|
||||
try:
|
||||
since_ts = parse_timestamp(since) if since else None
|
||||
until_ts = parse_timestamp(until) if until else None
|
||||
|
|
|
|||
Loading…
Reference in a new issue