diff --git a/backend/app.py b/backend/app.py index 3c3d264..2f6536c 100644 --- a/backend/app.py +++ b/backend/app.py @@ -639,16 +639,18 @@ async def reload_data( @limiter.limit("2/minute") async def reimport_ks2( request: Request, + geocode: bool = True, _: bool = Depends(verify_admin_api_key) ): """ Re-run the full KS2 CSV migration (drop + reimport schools and results). Use when the database has been wiped and needs repopulating from the CSV files. + Pass ?geocode=false to skip postcode → lat/lng resolution. Runs synchronously — expect this to take several minutes. Requires X-API-Key header with valid admin API key. """ loop = asyncio.get_event_loop() - success = await loop.run_in_executor(None, run_full_migration) + success = await loop.run_in_executor(None, lambda: run_full_migration(geocode=geocode)) if not success: raise HTTPException(status_code=500, detail="Migration failed: no CSV data found in data directory") clear_cache() diff --git a/integrator/scripts/sources/ks2.py b/integrator/scripts/sources/ks2.py index fb8d34b..4961585 100644 --- a/integrator/scripts/sources/ks2.py +++ b/integrator/scripts/sources/ks2.py @@ -22,8 +22,8 @@ def download(): def load(): - """Trigger full KS2 re-import via the backend admin endpoint.""" - url = f"{BACKEND_URL}/api/admin/reimport-ks2" + """Trigger full KS2 re-import via the backend admin endpoint (with geocoding).""" + url = f"{BACKEND_URL}/api/admin/reimport-ks2?geocode=true" print(f"POST {url}") resp = requests.post( url,