From 60ee3a65853c623ebb795d9bde7fb6f71c606389 Mon Sep 17 00:00:00 2001 From: Nolan Kovacs Date: Thu, 26 Mar 2026 14:12:08 -0400 Subject: [PATCH] j --- cache_builder.py | 33 ++++++++++++++++++++++++- release_beta.bat | 60 ++++++++++++++++++++++++++++++++++++++++++++++ release_stable.bat | 60 ++++++++++++++++++++++++++++++++++++++++++++++ updater.py | 2 +- 4 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 release_beta.bat create mode 100644 release_stable.bat diff --git a/cache_builder.py b/cache_builder.py index f4b14f6..117b6ca 100644 --- a/cache_builder.py +++ b/cache_builder.py @@ -1037,5 +1037,36 @@ def main() -> None: print("\nCache build complete.") +def phase5_only() -> None: + """Load fundamentals from DB and recompute sector stats — no cache rebuild.""" + print("=" * 55) + print(" PHASE 5 ONLY — Sector statistics recompute") + print(f" TABLE_PREFIX={_TABLE_PREFIX!r}") + print("=" * 55 + "\n") + + print(f"Loading fundamentals from {_TABLE_PREFIX}fundamentals_cache ...") + cols = [c for c in _FUND_COLS if c != "updated_at"] + col_str = ", ".join(f'"{c}"' for c in cols) + try: + conn = _get_conn() + with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: + cur.execute(f'SELECT {col_str} FROM "{_TABLE_PREFIX}fundamentals_cache"') + rows = cur.fetchall() + conn.close() + except Exception as e: + print(f"ERROR: Could not load fundamentals: {e}") + raise SystemExit(1) + + fundamentals = {r["ticker"]: dict(r) for r in rows} + print(f" Loaded {len(fundamentals)} rows\n") + + run_sector_stats_phase(fundamentals) + print("\nPhase 5 complete.") + + if __name__ == "__main__": - main() + import sys + if "--phase5-only" in sys.argv: + phase5_only() + else: + main() diff --git a/release_beta.bat b/release_beta.bat new file mode 100644 index 0000000..c96c3aa --- /dev/null +++ b/release_beta.bat @@ -0,0 +1,60 @@ +@echo off +setlocal + +echo ============================================================ +echo Release BETA (code deploy + exe build + beta user update) +echo ============================================================ +echo. + +set /p COMMIT_MSG=Commit message: +if "%COMMIT_MSG%"=="" ( + echo Error: Commit message cannot be empty. + pause + exit /b 1 +) + +set /p RELEASE_NOTES=Release notes (shown to users, press Enter to skip): + +echo. +echo [1/5] Staging all changes... +git add -A + +echo [2/5] Committing... +git commit -m "%COMMIT_MSG%" +if errorlevel 1 ( + echo Nothing to commit — continuing to build. +) + +echo [3/5] Pushing to Gitea beta branch... +git push gitea HEAD:beta +if errorlevel 1 ( + echo Push failed. Check Gitea connection. + pause + exit /b 1 +) + +echo [4/5] Deploying server-side files to VPS... +ssh root@87.99.133.95 "cd /srv/stock-tool-beta && git pull origin beta && cp api/main.py /srv/api/main.py && cp health_monitor.py /srv/health_monitor.py && pm2 restart api && echo VPS beta deploy OK" +if errorlevel 1 ( + echo VPS deploy failed. Check SSH connection. + pause + exit /b 1 +) + +echo [5/5] Building exe and pushing update to beta users... +if "%RELEASE_NOTES%"=="" ( + python push_update.py --channel beta +) else ( + python push_update.py --channel beta --notes "%RELEASE_NOTES%" +) +if errorlevel 1 ( + echo Exe build or upload failed. + pause + exit /b 1 +) + +echo. +echo ============================================================ +echo Beta release complete. Beta users will update on next launch. +echo ============================================================ +pause diff --git a/release_stable.bat b/release_stable.bat new file mode 100644 index 0000000..7bdc181 --- /dev/null +++ b/release_stable.bat @@ -0,0 +1,60 @@ +@echo off +setlocal + +echo ============================================================ +echo Release STABLE (code deploy + exe build + user update) +echo ============================================================ +echo. + +set /p COMMIT_MSG=Commit message: +if "%COMMIT_MSG%"=="" ( + echo Error: Commit message cannot be empty. + pause + exit /b 1 +) + +set /p RELEASE_NOTES=Release notes (shown to users, press Enter to skip): + +echo. +echo [1/5] Staging all changes... +git add -A + +echo [2/5] Committing... +git commit -m "%COMMIT_MSG%" +if errorlevel 1 ( + echo Nothing to commit — continuing to build. +) + +echo [3/5] Pushing to Gitea main branch... +git push gitea main +if errorlevel 1 ( + echo Push failed. Check Gitea connection. + pause + exit /b 1 +) + +echo [4/5] Deploying server-side files to VPS... +ssh root@87.99.133.95 "cd /srv/stock-tool && git pull && cp api/main.py /srv/api/main.py && cp health_monitor.py /srv/health_monitor.py && pm2 restart api && echo VPS deploy OK" +if errorlevel 1 ( + echo VPS deploy failed. Check SSH connection. + pause + exit /b 1 +) + +echo [5/5] Building exe and pushing update to users... +if "%RELEASE_NOTES%"=="" ( + python push_update.py --channel stable +) else ( + python push_update.py --channel stable --notes "%RELEASE_NOTES%" +) +if errorlevel 1 ( + echo Exe build or upload failed. + pause + exit /b 1 +) + +echo. +echo ============================================================ +echo Stable release complete. Users will update on next launch. +echo ============================================================ +pause diff --git a/updater.py b/updater.py index 65e08ce..dbd5a19 100644 --- a/updater.py +++ b/updater.py @@ -19,7 +19,7 @@ import requests # --------------------------------------------------------------------------- # Current app version — kept in sync by push_update.py before each build. # --------------------------------------------------------------------------- -APP_VERSION = "1.3.8" +APP_VERSION = "1.3.9" def _exe_dir() -> str: