fix(fulfillment): 为商品能力全局补扫保留队列槽位

This commit is contained in:
yml
2026-11-28 21:04:19 +08:00
parent 7ca011c14e
commit 371027d730
5 changed files with 61 additions and 8 deletions
@@ -33,6 +33,7 @@ from ...platform_fulfillment.account_selector import (
)
JOB_KEY = "account_capability_refresh"
DEFAULT_BACKFILL_RESERVED_SLOTS = 8
def _pending_demand_rows(
@@ -125,27 +126,30 @@ def _refresh_candidates(
100,
),
)
backfill_reserved = min(
DEFAULT_BACKFILL_RESERVED_SLOTS,
max(0, batch // 4),
)
demand_candidates = (
capability_refresh_candidate_accounts(
db,
commodity_ids=commodity_ids,
scope="elite",
limit=batch,
limit=batch - backfill_reserved,
now=moment,
)
if commodity_ids
if commodity_ids and batch > backfill_reserved
else []
)
demand_ids = {int(account.id) for account in demand_candidates}
remaining = batch - len(demand_candidates)
backfill_candidates = (
storehome_refresh_candidate_accounts(
db,
limit=remaining,
limit=batch - len(demand_candidates),
now=moment,
exclude_account_ids=tuple(demand_ids),
)
if remaining > 0
if batch > len(demand_candidates)
else []
)
accounts = [*demand_candidates, *backfill_candidates]