Replace purge_db.py with seed.db bootstrap (827 CPU rows pre-seeded for new users)
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -12,8 +12,9 @@ env/
|
|||||||
ENV/
|
ENV/
|
||||||
|
|
||||||
# ── Database ──────────────────────────────────────────────────────────────────
|
# ── Database ──────────────────────────────────────────────────────────────────
|
||||||
# The live database is never committed – only cpu_specs is preserved via the
|
# The live database is never committed. seed.db (cpu_specs only) IS committed
|
||||||
# bundled seed dump (if one is created). See purge_db.py before committing.
|
# and serves as the starting point for new users. Regenerate it with:
|
||||||
|
# python _dev/export_seed_db.py
|
||||||
database.db
|
database.db
|
||||||
database.db-shm
|
database.db-shm
|
||||||
database.db-wal
|
database.db-wal
|
||||||
@@ -26,7 +27,6 @@ logs/
|
|||||||
browser_data/
|
browser_data/
|
||||||
|
|
||||||
# ── Maintenance / dev scripts (not part of the shipped app) ──────────────────
|
# ── Maintenance / dev scripts (not part of the shipped app) ──────────────────
|
||||||
purge_db.py
|
|
||||||
_dev/
|
_dev/
|
||||||
|
|
||||||
# ── OS / editor noise ─────────────────────────────────────────────────────────
|
# ── OS / editor noise ─────────────────────────────────────────────────────────
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -29,6 +29,14 @@ from scrapers.shared import init_db, DB_PATH as _SCRAPER_DB_PATH
|
|||||||
# ── Flask app ─────────────────────────────────────────────────────────────────
|
# ── Flask app ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
DB_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "database.db")
|
DB_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "database.db")
|
||||||
|
SEED_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "seed.db")
|
||||||
|
|
||||||
|
# ── Seed bootstrap ────────────────────────────────────────────────────────────
|
||||||
|
# On first run, if no database exists yet but a seed.db is bundled, copy it
|
||||||
|
# into place so users start with pre-populated CPU data.
|
||||||
|
if not os.path.exists(DB_PATH) and os.path.exists(SEED_PATH):
|
||||||
|
import shutil
|
||||||
|
shutil.copy2(SEED_PATH, DB_PATH)
|
||||||
|
|
||||||
app = Flask(__name__, static_folder="static", static_url_path="/static")
|
app = Flask(__name__, static_folder="static", static_url_path="/static")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user