diff --git a/nike/server.py b/nike/server.py index c058771..7fcc8be 100644 --- a/nike/server.py +++ b/nike/server.py @@ -849,6 +849,21 @@ async def api_cache_invalidate(): }) +@dashboard.post("/api/sync") +async def api_sync(): + """Cache refresh — replaces the legacy API-Football DB sync.""" + start = time.perf_counter() + db.invalidate_cache("%") + api.clear_cache() + duration = round(time.perf_counter() - start, 2) + return JSONResponse({ + "ok": True, + "result": {"players": 0, "seasons": {}}, + "duration_s": duration, + "note": "Cache cleared; fresh data will be fetched on next request.", + }) + + # ── Tool runner API ─────────────────────────────────────── _TOOLS: dict[str, Any] = {} # populated after tool definitions exist diff --git a/nike/templates/dashboard.html b/nike/templates/dashboard.html index 56103d9..4f3f3bc 100644 --- a/nike/templates/dashboard.html +++ b/nike/templates/dashboard.html @@ -225,7 +225,7 @@
@@ -437,29 +437,28 @@ const btn = document.getElementById('syncBtn'); const result = document.getElementById('syncResult'); btn.disabled = true; - btn.innerHTML = 'Syncing…'; + btn.innerHTML = 'Refreshing…'; result.textContent = ''; - document.getElementById('syncToastBody').textContent = 'Sync started — this takes ~10 seconds…'; + document.getElementById('syncToastBody').textContent = 'Clearing cache…'; toast.show(); try { const resp = await fetch('/api/sync', { method: 'POST' }); const data = await resp.json(); if (data.ok) { - const r = data.result; - result.innerHTML = `✅ Synced ${r.players} players, ${Object.values(r.seasons || {}).reduce((a,b)=>a+b,0)} fixtures in ${data.duration_s}s`; - document.getElementById('syncToastBody').textContent = `Sync complete in ${data.duration_s}s`; + result.innerHTML = `✅ Cache cleared in ${data.duration_s}s`; + document.getElementById('syncToastBody').textContent = `Cache cleared in ${data.duration_s}s`; await refreshStatus(); } else { result.innerHTML = `❌ ${data.error}`; - document.getElementById('syncToastBody').textContent = 'Sync failed: ' + data.error; + document.getElementById('syncToastBody').textContent = 'Refresh failed: ' + data.error; } } catch (e) { result.innerHTML = `❌ Network error`; } finally { btn.disabled = false; - btn.innerHTML = 'Sync TFC Data'; + btn.innerHTML = 'Refresh Cache'; } }