@echo off
chcp 65001 >nul
setlocal
title Server repredict ALL profiles (2020-2026)
echo ============================================================
echo   Server: import_all_race_ai_compare_profiles.py
echo   profile: all (p1..p6)  from 2020-01-01 to 2026-12-31
echo ============================================================
echo.

call "%~dp0_load-env.bat"
if errorlevel 1 goto end

echo server: %SERVER_SSH%
echo path:   %SERVER_PATH%
echo.
echo Runs in background on server. May take many hours (6 profiles x ~20k races).
pause

ssh -o StrictHostKeyChecking=no %SERVER_SSH% "cd %SERVER_PATH% && mkdir -p logs && BACKFILL_FROM_DATE=2020-01-01 BACKFILL_TO_DATE=2026-12-31 ./scripts/backfill_data_and_repredict.sh repredict-all && sleep 2 && ls -t logs/import_all_profiles.*.log 2>/dev/null | head -1 | xargs tail -5"
if errorlevel 1 (
  echo [NG] failed to start
  goto end
)

echo.
echo [OK] started in background.
echo  progress: ssh %SERVER_SSH% "ls -t %SERVER_PATH%/logs/import_all_profiles.*.log ^| head -1 ^| xargs tail -f"
echo.

:end
pause
endlocal
