Add machine filter on trade records and review list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-17 22:15:22 +08:00
parent 7bf04e3c68
commit 3164a21348
3 changed files with 58 additions and 30 deletions
+16 -3
View File
@@ -594,12 +594,25 @@ def register_routes(app: Flask) -> None:
@login_required
def records_page():
u = current_user()
machine_raw = (request.args.get("machine_id") or "").strip()
machine_id = int(machine_raw) if machine_raw.isdigit() else None
with database.get_db() as conn:
machines = database.list_machines_for_user(conn, u)
allowed_ids = {int(m["id"]) for m in machines}
if machine_id is not None and machine_id not in allowed_ids:
machine_id = None
if u["role"] == "admin":
trades = database.list_trades(conn, 300)
trades = database.list_trades(conn, 300, machine_id=machine_id)
else:
trades = database.list_trades(conn, 300, account_id=u.get("account_id"))
return render_template("records.html", trades=trades)
trades = database.list_trades(
conn, 300, account_id=u.get("account_id"), machine_id=machine_id
)
return render_template(
"records.html",
trades=trades,
machines=machines,
selected_machine_id=machine_id,
)
@app.get("/records/<int:tid>")
@login_required