同步完成后自动刷新页面更新数据条数,修复持仓同步未提交事务,加大按钮间距

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 14:47:54 +08:00
parent 19203c050c
commit 012b220c60
3 changed files with 33 additions and 4 deletions
+6 -1
View File
@@ -5,7 +5,7 @@ from app.database import SessionLocal
from app.models import DailyBar, Contract
from app.engine.lock_strategy import compute_amp_5d
_progress = {"running": False, "label": "", "done": 0, "total": 0, "finished": False}
_progress = {"running": False, "label": "", "done": 0, "total": 0, "result": 0, "finished": False}
_lock = threading.Lock()
@@ -78,6 +78,8 @@ def sync_contract_bars_bg(contract_code: str) -> bool:
db.flush()
_recompute_amp(db, code, from_date=min_date)
db.commit()
with _lock:
_progress["result"] = inserted
finally:
db.close()
@@ -132,6 +134,9 @@ def sync_positions_bg(contract_code: str) -> bool:
with _lock:
_progress["done"] = i + 1
_progress["label"] = f"同步持仓 {code} · {i + 1}/{total_missing}"
db.commit()
with _lock:
_progress["result"] = inserted
finally:
db.close()