seeding expansion
also: replace energy output with energy output density
This commit is contained in:
51
src/physcom_web/routes/admin.py
Normal file
51
src/physcom_web/routes/admin.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Admin panel routes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, flash, redirect, render_template, url_for
|
||||
|
||||
from physcom.seed.transport_example import load_transport_seed
|
||||
from physcom_web.app import get_repo
|
||||
|
||||
bp = Blueprint("admin", __name__, url_prefix="/admin")
|
||||
|
||||
|
||||
@bp.route("/")
|
||||
def admin_index():
|
||||
repo = get_repo()
|
||||
entities = repo.list_entities()
|
||||
domains = repo.list_domains()
|
||||
status_counts = repo.count_combinations_by_status()
|
||||
runs = repo.list_pipeline_runs()
|
||||
stats = {
|
||||
"entities": len(entities),
|
||||
"domains": len(domains),
|
||||
"combinations": sum(status_counts.values()),
|
||||
"pipeline_runs": len(runs),
|
||||
}
|
||||
return render_template("admin/index.html", stats=stats)
|
||||
|
||||
|
||||
@bp.route("/reseed", methods=["POST"])
|
||||
def reseed():
|
||||
repo = get_repo()
|
||||
counts = load_transport_seed(repo)
|
||||
total = counts["platforms"] + counts["power_sources"]
|
||||
flash(
|
||||
f"Reseed complete — added {total} entities, {counts['domains']} domains.",
|
||||
"success",
|
||||
)
|
||||
return redirect(url_for("admin.admin_index"))
|
||||
|
||||
|
||||
@bp.route("/wipe-and-reseed", methods=["POST"])
|
||||
def wipe_and_reseed():
|
||||
repo = get_repo()
|
||||
repo.clear_all()
|
||||
counts = load_transport_seed(repo)
|
||||
total = counts["platforms"] + counts["power_sources"]
|
||||
flash(
|
||||
f"Wiped all data and reseeded — {total} entities, {counts['domains']} domains.",
|
||||
"success",
|
||||
)
|
||||
return redirect(url_for("admin.admin_index"))
|
||||
Reference in New Issue
Block a user