feat(ks2): enable geocoding during reimport
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 47s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m3s
Build and Push Docker Images / Build Integrator (push) Successful in 56s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 47s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m3s
Build and Push Docker Images / Build Integrator (push) Successful in 56s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
Add geocode query param to /api/admin/reimport-ks2 (defaults true). ks2.py passes ?geocode=true so postcodes are resolved to lat/lng in the same migration pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user