fix(map): geofence delete, vessel snapshots, sentinel cache, news briefs
Geofences could be drawn but not removed. VesselAPI Hormuz dots vanished
on restart and DVR skipped between the 5 daily polls. Sentinel-1 re-hit
STAC on every pan and often painted a neighbouring swath. Executive
briefs truncated; ticker stayed empty unless something was critical.
- Layer-panel list + polygon popup DELETE /api/geofences/{id}
- Persist VesselAPI polls to vessels (UTC-day purge, DVR as-of, boot hydrate)
- Cache Sentinel-1 by 2° cell; pick covering scene; clip Leaflet tiles
- Retry truncated LLM JSON; ticker falls back to medium/low; 3-min HUD poll
This commit is contained in:
parent
fdf5969e27
commit
c48788d4b6
20 changed files with 669 additions and 57 deletions
33
app/main.py
33
app/main.py
|
|
@ -74,6 +74,11 @@ async def _lifespan(app: FastAPI):
|
|||
await refresh_cache()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from vesselapi import hydrate_last_known
|
||||
await hydrate_last_known()
|
||||
except Exception:
|
||||
pass
|
||||
from config import AISSTREAM_IN_APP, VESSELAPI_IN_APP
|
||||
ais_task = None
|
||||
vesselapi_task = None
|
||||
|
|
@ -1263,6 +1268,7 @@ async def list_news_summaries(
|
|||
|
||||
|
||||
_FLAGGED = ("critical", "high")
|
||||
_LESSER = ("medium", "low")
|
||||
|
||||
|
||||
@app.get("/api/news/ticker", response_model=list[NewsTickerItemOut])
|
||||
|
|
@ -1273,7 +1279,7 @@ async def list_news_ticker(
|
|||
),
|
||||
limit: int = Query(20, ge=1, le=50),
|
||||
):
|
||||
"""Flagged ticker rows (critical/high), newest first. No LLM required."""
|
||||
"""Ticker rows: critical/high first; medium/low if nothing is flagged."""
|
||||
async with async_session() as session:
|
||||
stmt = (
|
||||
select(news_items)
|
||||
|
|
@ -1287,6 +1293,19 @@ async def list_news_ticker(
|
|||
stmt = stmt.where(news_items.c.created_at >= since)
|
||||
stmt = stmt.limit(limit)
|
||||
rows = (await session.execute(stmt)).mappings().all()
|
||||
if not rows:
|
||||
stmt = (
|
||||
select(news_items)
|
||||
.where(
|
||||
news_items.c.kind == "ticker",
|
||||
news_items.c.importance.in_(_LESSER),
|
||||
)
|
||||
.order_by(news_items.c.created_at.desc())
|
||||
)
|
||||
if since:
|
||||
stmt = stmt.where(news_items.c.created_at >= since)
|
||||
stmt = stmt.limit(limit)
|
||||
rows = (await session.execute(stmt)).mappings().all()
|
||||
return [
|
||||
NewsTickerItemOut(
|
||||
id=r["id"], headline=r["headline"], importance=r["importance"],
|
||||
|
|
@ -1530,7 +1549,17 @@ async def list_vessels(
|
|||
from tracks import fetch_positions_at, parse_timestamp
|
||||
ts = parse_timestamp(timestamp)
|
||||
if ts is not None:
|
||||
return overlay_json(await fetch_positions_at("vessel", ts, bbox, limit), 5)
|
||||
from vesselapi import fetch_vessels_as_of
|
||||
if src == "vesselapi":
|
||||
return overlay_json(await fetch_vessels_as_of(ts, bbox, limit), 5)
|
||||
ais = await fetch_positions_at("vessel", ts, bbox, limit)
|
||||
if src == "aisstream":
|
||||
return overlay_json(ais, 5)
|
||||
va = await fetch_vessels_as_of(ts, bbox, limit)
|
||||
by_id = {m["id"]: m for m in ais}
|
||||
for m in va:
|
||||
by_id[m["id"]] = m
|
||||
return overlay_json(list(by_id.values())[:limit], 5)
|
||||
return overlay_json(await fetch_vessels(bbox, limit, src=src), 5)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(422, str(exc)) from exc
|
||||
|
|
|
|||
Loading…
Reference in a new issue