perf(douyu): 优化慢查询并修复供应商充值收口
This commit is contained in:
@@ -84,14 +84,6 @@ def build_select_query(
|
||||
)
|
||||
|
||||
|
||||
def count_remaining(
|
||||
db: Session,
|
||||
*,
|
||||
now: datetime | None = None,
|
||||
) -> int:
|
||||
return _base_query(db, now or datetime.now(UTC)).count()
|
||||
|
||||
|
||||
def run_account_capability_refresh(
|
||||
db: Session,
|
||||
job: AutomationJob,
|
||||
@@ -103,7 +95,9 @@ def run_account_capability_refresh(
|
||||
job,
|
||||
accounts,
|
||||
now=now,
|
||||
remaining_count=count_remaining(db, now=now),
|
||||
# 精确剩余量要完整评估 accounts × commodity EXISTS,生产实测单次约
|
||||
# 1.3 秒、扫描 38 万行;它只用于展示,直接省略,避免每轮制造慢查询。
|
||||
remaining_count=None,
|
||||
source="capability_demand_refresh",
|
||||
log_label="capability",
|
||||
empty_message="当前履约商品没有到期待刷新的账号能力",
|
||||
@@ -113,6 +107,5 @@ def run_account_capability_refresh(
|
||||
__all__ = [
|
||||
"JOB_KEY",
|
||||
"build_select_query",
|
||||
"count_remaining",
|
||||
"run_account_capability_refresh",
|
||||
]
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
- 不删行、只删「过期的整行」:不做「把 result 清空保留行」这种半吊子操作,
|
||||
因为部分前端派生**明确要求 result 非空**,清空等于制造「有行但读不出状态」的
|
||||
更隐蔽的坏状态;
|
||||
- 作业**默认关闭**(`ensure_jobs` 建行时 enabled=False),由运维在页面上打开。
|
||||
- 作业**默认启用**(`ensure_jobs` 建行时 enabled=True),避免执行日志无限增长;
|
||||
运维仍可在页面上关闭。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
Reference in New Issue
Block a user