feat(accounts): 增加账号供给画像投影
- 新增 account_supply_profiles 表与迁移 - 按租约/生命周期/价值/能力计算角色、质量分、冗余 - 新增 account_supply_profile_projection 作业,默认开启 - 账号列表展示供给画像列 - 补充画像角色/评分/游标/作业测试
This commit is contained in:
@@ -13,6 +13,7 @@ from ..models import (
|
||||
Account,
|
||||
AccountCommodityState,
|
||||
AccountEvent,
|
||||
AccountSupplyProfile,
|
||||
AuditLog,
|
||||
DouyuTask,
|
||||
User,
|
||||
@@ -616,6 +617,16 @@ def list_accounts(
|
||||
count, last_at, _ = exchange_stats[key]
|
||||
exchange_stats[key] = (count, last_at, str(title or ""))
|
||||
|
||||
profile_map = (
|
||||
{
|
||||
int(row.account_id): row
|
||||
for row in db.query(AccountSupplyProfile)
|
||||
.filter(AccountSupplyProfile.account_id.in_(ids))
|
||||
.all()
|
||||
}
|
||||
if ids
|
||||
else {}
|
||||
)
|
||||
result = []
|
||||
for acc in accounts:
|
||||
eff_kind = acc.relogin_failure_kind or ""
|
||||
@@ -652,6 +663,18 @@ def list_accounts(
|
||||
# 只返回官方 storehome 的紧凑三态,不把整份快照带进列表。
|
||||
high_value=high_value_payload(acc),
|
||||
overview_queried_at=acc.overview_queried_at,
|
||||
supply_role=(
|
||||
profile_map[acc.id].supply_role if acc.id in profile_map else ""
|
||||
),
|
||||
quality_score=(
|
||||
profile_map[acc.id].quality_score if acc.id in profile_map else None
|
||||
),
|
||||
redundancy_class=(
|
||||
profile_map[acc.id].redundancy_class if acc.id in profile_map else ""
|
||||
),
|
||||
ck_remaining_hours=(
|
||||
profile_map[acc.id].ck_remaining_hours if acc.id in profile_map else None
|
||||
),
|
||||
)
|
||||
# 只有管理员可看完整字段(密码、邮箱等)
|
||||
if can_include_sensitive:
|
||||
|
||||
Reference in New Issue
Block a user