mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-10-11 01:18:45 +02:00
fix: restore CCTV and Telegram map visibility
This commit is contained in:
1 parent
ae87fc6bfb
commit
2461756da4
5 files changed
+60
-3
No files matched your search
@@ -299,6 +299,9 @@ class BaseCCTVIngestor(ABC):
|
||||
pass
|
||||
|
||||
def ingest(self):
|
||||
# Ingestors may run independently (including from worker threads), so
|
||||
# make sure a fresh checkout has both the directory and schema ready.
|
||||
init_db()
|
||||
conn = sqlite3.connect(str(DB_PATH))
|
||||
try:
|
||||
cameras = self.fetch_data()
|
||||
|
||||
@@ -51,8 +51,15 @@ def _instant_fetch(key: str) -> None:
|
||||
|
||||
def _slow_fetch(key: str) -> None:
|
||||
if key == "cctv":
|
||||
from services.cctv_pipeline import get_camera_count, run_all_ingestors
|
||||
from services.fetchers.infrastructure import fetch_cctv
|
||||
|
||||
# A fresh checkout can have an empty SQLite catalog even though the
|
||||
# public camera feeds are available. Seed it the first time CCTV is
|
||||
# enabled; otherwise the layer stays ON with zero map records until a
|
||||
# later scheduler cycle happens to run.
|
||||
if get_camera_count() == 0:
|
||||
run_all_ingestors()
|
||||
fetch_cctv()
|
||||
logger.info("CCTV loaded (layer enabled)")
|
||||
return
|
||||
|
||||
@@ -56,3 +56,35 @@ def test_refresh_cctv_runs_on_slow_executor():
|
||||
assert slow_exec.submit.call_args[0][1] == ("cctv",)
|
||||
|
||||
active_layers["cctv"] = before.get("cctv", False)
|
||||
|
||||
|
||||
def test_cctv_enable_seeds_empty_catalog_before_loading():
|
||||
"""An empty CCTV DB must trigger the public ingestors on first enable."""
|
||||
from services.layer_enable_refresh import _slow_fetch
|
||||
|
||||
with (
|
||||
patch("services.cctv_pipeline.get_camera_count", return_value=0) as count,
|
||||
patch("services.cctv_pipeline.run_all_ingestors") as seed,
|
||||
patch("services.fetchers.infrastructure.fetch_cctv") as fetch_cctv,
|
||||
):
|
||||
_slow_fetch("cctv")
|
||||
|
||||
count.assert_called_once()
|
||||
seed.assert_called_once()
|
||||
fetch_cctv.assert_called_once()
|
||||
|
||||
|
||||
def test_cctv_enable_reuses_nonempty_catalog():
|
||||
"""A populated CCTV DB should stay fast and avoid re-seeding on enable."""
|
||||
from services.layer_enable_refresh import _slow_fetch
|
||||
|
||||
with (
|
||||
patch("services.cctv_pipeline.get_camera_count", return_value=12) as count,
|
||||
patch("services.cctv_pipeline.run_all_ingestors") as seed,
|
||||
patch("services.fetchers.infrastructure.fetch_cctv") as fetch_cctv,
|
||||
):
|
||||
_slow_fetch("cctv")
|
||||
|
||||
count.assert_called_once()
|
||||
seed.assert_not_called()
|
||||
fetch_cctv.assert_called_once()
|
||||
@@ -88,6 +88,19 @@ describe('MaplibreViewer behavior — CCTV proxy wiring', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('MaplibreViewer behavior — Telegram visibility fallback', () => {
|
||||
const viewer = fs.readFileSync(path.join(COMP_DIR, 'MaplibreViewer.tsx'), 'utf-8');
|
||||
|
||||
it('keeps a visible MapLibre fallback while HTML pins are temporarily hidden', () => {
|
||||
const telegramSection = viewer.slice(
|
||||
viewer.indexOf('<Source id="telegram-osint-source"'),
|
||||
viewer.indexOf('</Source>', viewer.indexOf('<Source id="telegram-osint-source"')) + '</Source>'.length,
|
||||
);
|
||||
expect(telegramSection).toContain('minzoom={2}');
|
||||
expect(telegramSection).toContain("'circle-opacity': 0.65");
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Popup subscription isolation ─────────────────────────────────────────
|
||||
|
||||
describe('MaplibreViewer behavior — popup components have no keyed subscriptions', () => {
|
||||
|
||||
@@ -3856,7 +3856,7 @@ const MaplibreViewer = ({
|
||||
<Layer
|
||||
id="telegram-osint-layer"
|
||||
type="circle"
|
||||
minzoom={4}
|
||||
minzoom={2}
|
||||
paint={{
|
||||
'circle-radius': [
|
||||
'interpolate',
|
||||
@@ -3870,9 +3870,11 @@ const MaplibreViewer = ({
|
||||
['case', ['>', ['get', 'post_count'], 1], 26, 22],
|
||||
],
|
||||
'circle-color': '#ef4444',
|
||||
'circle-stroke-width': 0,
|
||||
'circle-stroke-width': 1,
|
||||
'circle-stroke-color': '#fca5a5',
|
||||
'circle-opacity': 0,
|
||||
// Keep a visible MapLibre fallback while the HTML pins are
|
||||
// temporarily suppressed during map interaction.
|
||||
'circle-opacity': 0.65,
|
||||
}}
|
||||
/>
|
||||
</Source>
|
||||
|
||||
Reference in new issue
Block a user