perf(fulfillment): 优化能力刷新候选查询并新增精英能力投影
This commit is contained in:
@@ -153,6 +153,13 @@ class Account(Base):
|
||||
# 账号价值 1-5 档的后台投影。为空时查询会回退实时 CASE,便于新账号和
|
||||
# 灰度期间保持正确;生产行由 account_value_projection 作业周期性刷新。
|
||||
value_tier: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
# 精英域商品能力摘要投影(elite_covered=None 表示尚未投影,查询回退子查询)。
|
||||
# 由 account_capability_service 在写入 account_commodity_states 时同步维护,
|
||||
# 避免全局库存汇总每次扫描全量 68 万+ 商品明细行。
|
||||
elite_covered: Mapped[bool | None] = mapped_column(Boolean, nullable=True)
|
||||
elite_eligible_until: Mapped[datetime | None] = mapped_column(
|
||||
UTCDateTime, nullable=True
|
||||
)
|
||||
# 积分**到期时刻**(斗鱼在积分查询里给 `willExpireTime`,只有送礼后的那次查询才有)。
|
||||
# 积分到期是账号资产的真实减少,但斗鱼不会「通知」你 —— 所以这里记下到期时刻,
|
||||
# 由作业在到期后补记一条 `points_expire` 事件(否则这个减少在时间线上是空白)。
|
||||
@@ -307,6 +314,16 @@ class Account(Base):
|
||||
# 高价值三态的过期判定和待刷新筛选
|
||||
Index("ix_accounts_high_value_checked_at", "high_value_checked_at"),
|
||||
Index("ix_accounts_value_tier", "value_tier", "id"),
|
||||
Index(
|
||||
"ix_accounts_elite_supply",
|
||||
"auto_managed",
|
||||
"ck_check_status",
|
||||
"status",
|
||||
"elite_covered",
|
||||
"elite_eligible_until",
|
||||
"value_tier",
|
||||
"id",
|
||||
),
|
||||
# 账号池选号:先按自动管理/生命周期过滤,再按 CK、积分和到期时间排序。
|
||||
# 这条索引避免每次选号都回表扫描全部账号后再排序。
|
||||
Index(
|
||||
|
||||
Reference in New Issue
Block a user