fix(douyu): 拆分账号资格活动窗口与库存语义
This commit is contained in:
@@ -387,6 +387,28 @@ def account_platform_status(
|
||||
}
|
||||
fresh_available = int(commodities.get(AVAILABILITY_AVAILABLE, {}).get("fresh", 0))
|
||||
fresh_limited = int(commodities.get(AVAILABILITY_LIMITED, {}).get("fresh", 0))
|
||||
eligibility_rows = (
|
||||
db.query(
|
||||
AccountCommodityState.account_eligibility,
|
||||
func.count(AccountCommodityState.id),
|
||||
func.sum(
|
||||
case(
|
||||
(AccountCommodityState.valid_until > moment, 1),
|
||||
else_=0,
|
||||
)
|
||||
),
|
||||
)
|
||||
.filter(AccountCommodityState.platform == "douyu")
|
||||
.group_by(AccountCommodityState.account_eligibility)
|
||||
.all()
|
||||
)
|
||||
eligibility = {
|
||||
str(state): {
|
||||
"total": int(total or 0),
|
||||
"fresh": int(fresh or 0),
|
||||
}
|
||||
for state, total, fresh in eligibility_rows
|
||||
}
|
||||
|
||||
inventories = evaluate_supply_targets(db, now=moment)
|
||||
supply_targets: list[dict[str, Any]] = []
|
||||
@@ -529,6 +551,8 @@ def account_platform_status(
|
||||
"sync_domains": sync_domains,
|
||||
"commodities": {
|
||||
"by_availability": commodities,
|
||||
"by_account_eligibility": eligibility,
|
||||
"fresh_eligible": int(eligibility.get("eligible", {}).get("fresh", 0)),
|
||||
"fresh_available": fresh_available,
|
||||
"fresh_limited": fresh_limited,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user