feat: sync account priorities after rate changes

This commit is contained in:
liumangmang
2026-05-29 17:51:12 +08:00
parent c5778bb3e7
commit 5c20ddc8e6
21 changed files with 1510 additions and 26 deletions
+12
View File
@@ -160,6 +160,7 @@ def _check_upstream(upstream_id: int) -> None:
if changes:
_notify_rate_changed(upstream_id, upstream.name, upstream.base_url, changes)
_sync_website_bindings(upstream_id, changes)
_sync_account_priorities(upstream_id)
if balance_alert_triggered:
_notify_balance_low(
@@ -284,6 +285,17 @@ def _sync_upstream_keys(upstream_id: int, snapshot: dict[str, Any], captured_at:
db.close()
def _sync_account_priorities(upstream_id: int) -> None:
"""倍率变更后自动更新已导入下游账号的 priority。"""
db = SessionLocal()
try:
website_sync.sync_account_priorities_for_upstream(db, upstream_id)
except Exception:
logger.exception("account priority sync failed for upstream %s", upstream_id)
finally:
db.close()
def _sync_website_bindings(upstream_id: int, changes: list[dict[str, Any]]) -> None:
db = SessionLocal()
try: