perf(automation): 持久队列驱动并优化履约热路径
This commit is contained in:
@@ -150,6 +150,9 @@ class Account(Base):
|
||||
overview_queried_at: Mapped[datetime | None] = mapped_column(
|
||||
UTCDateTime, nullable=True
|
||||
)
|
||||
# 账号价值 1-5 档的后台投影。为空时查询会回退实时 CASE,便于新账号和
|
||||
# 灰度期间保持正确;生产行由 account_value_projection 作业周期性刷新。
|
||||
value_tier: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
# 积分**到期时刻**(斗鱼在积分查询里给 `willExpireTime`,只有送礼后的那次查询才有)。
|
||||
# 积分到期是账号资产的真实减少,但斗鱼不会「通知」你 —— 所以这里记下到期时刻,
|
||||
# 由作业在到期后补记一条 `points_expire` 事件(否则这个减少在时间线上是空白)。
|
||||
@@ -288,6 +291,7 @@ class Account(Base):
|
||||
Index("ix_accounts_status", "status"),
|
||||
# 高价值三态的过期判定和待刷新筛选
|
||||
Index("ix_accounts_high_value_checked_at", "high_value_checked_at"),
|
||||
Index("ix_accounts_value_tier", "value_tier", "id"),
|
||||
# 账号池选号:先按自动管理/生命周期过滤,再按 CK、积分和到期时间排序。
|
||||
# 这条索引避免每次选号都回表扫描全部账号后再排序。
|
||||
Index(
|
||||
@@ -463,6 +467,13 @@ class DouyuTask(Base):
|
||||
"next_run_at",
|
||||
"id",
|
||||
),
|
||||
Index(
|
||||
"ix_douyu_tasks_retention_scan",
|
||||
"task_type",
|
||||
"status",
|
||||
"created_at",
|
||||
"id",
|
||||
),
|
||||
Index(
|
||||
"uq_douyu_tasks_active_binding",
|
||||
"active_binding_key",
|
||||
@@ -2670,6 +2681,36 @@ class AccountSupplyTarget(Base):
|
||||
)
|
||||
|
||||
|
||||
class AccountSupplySnapshot(Base):
|
||||
"""供给目标的最近一次聚合结果,隔离页面读取与重型账号扫描。"""
|
||||
|
||||
__tablename__ = "account_supply_snapshots"
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
target_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("account_supply_targets.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
unique=True,
|
||||
)
|
||||
covered: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0, server_default="0"
|
||||
)
|
||||
available: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0, server_default="0"
|
||||
)
|
||||
allocatable: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0, server_default="0"
|
||||
)
|
||||
checked_at: Mapped[datetime] = mapped_column(UTCDateTime, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
UTCDateTime, default=_utcnow, onupdate=_utcnow
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_account_supply_snapshot_checked", "checked_at"),
|
||||
)
|
||||
|
||||
|
||||
class LoginAttempt(Base):
|
||||
"""一次完整登录/重登/账号检测尝试,只追加。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user