fix(growth): partition Yahoo promotion candidates
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-15 13:15:33 +08:00
parent 4670f80f98
commit c091c466c2
6 changed files with 139 additions and 13 deletions

View File

@@ -103,7 +103,7 @@ def run_pchome_growth_momo_backfill(
sync_func: Callable[[Any, list[dict[str, Any]]], dict[str, Any]] | None = None,
sync_review_func: Callable[[Any, list[dict[str, Any]]], dict[str, Any]] | None = None,
readback_func: Callable[[Any, list[dict[str, Any]]], dict[str, Any]] | None = None,
source_profile: dict[str, str] | None = None,
source_profile: dict[str, Any] | None = None,
source_activation_func: Callable[..., dict[str, Any]] | None = None,
source_rollback_func: Callable[..., dict[str, Any]] | None = None,
) -> dict[str, Any]:
@@ -121,6 +121,12 @@ def run_pchome_growth_momo_backfill(
**(source_profile or {}),
}
source_label = str(profile.get("display_name") or "外部平台")
formal_compare_types = {
str(item)
for item in (
profile.get("formal_compare_types") or ("total_price", "unit_price")
)
}
identity = new_reconciliation_identity(
str(profile.get("work_item_id") or "GROWTH-P0-001-B")
)
@@ -172,6 +178,24 @@ def run_pchome_growth_momo_backfill(
exact_candidates = [item for item in auto_candidates if candidate_auto_compare_type(item) == "total_price"]
unit_candidates = [item for item in auto_candidates if candidate_auto_compare_type(item) == "unit_price"]
review_candidates = list(candidate_verification.get("review_candidates") or [])
promotion_policy_deferred = []
for candidate in [*exact_candidates, *unit_candidates]:
compare_type = candidate_auto_compare_type(candidate)
if compare_type in formal_compare_types:
continue
deferred = dict(candidate)
deferred["promotion_policy_status"] = "candidate_only"
deferred["promotion_policy_reason"] = (
"source_profile_compare_type_not_allowed"
)
promotion_policy_deferred.append(deferred)
review_candidates.extend(promotion_policy_deferred)
exact_candidates = [
item for item in exact_candidates if "total_price" in formal_compare_types
]
unit_candidates = [
item for item in unit_candidates if "unit_price" in formal_compare_types
]
auto_candidates = [*exact_candidates, *unit_candidates]
external_offer_sync = {
"success": True,
@@ -324,11 +348,13 @@ def run_pchome_growth_momo_backfill(
"formal_price_write_requires_independent_verifier": True,
"pixelrag_direct_price_write_allowed": False,
"source_activation_requires_canary_readback": bool(source_activation_func),
"formal_compare_types": sorted(formal_compare_types),
},
"check_mode": {
"receipt_schema_ready": bool(schema_receipt.get("success")),
"verified_candidate_count": len(auto_candidates),
"blocked_candidate_count": int(candidate_verification.get("blocked_candidate_count") or 0),
"promotion_policy_deferred_count": len(promotion_policy_deferred),
},
"execution": {
"idempotent_bounded_execution": True,
@@ -395,6 +421,7 @@ def run_pchome_growth_momo_backfill(
"unit_compare_count": len(unit_candidates),
"auto_compare_count": len(auto_candidates),
"review_count": len(review_candidates),
"promotion_policy_deferred_count": len(promotion_policy_deferred),
"external_offer_sync": external_offer_sync,
"review_candidate_sync": review_candidate_sync,
"source_activation": source_activation,

View File

@@ -281,6 +281,7 @@ def run_pchome_growth_yahoo_backfill(
"display_name": SOURCE_LABEL,
"receipt_source": CONNECTOR_KEY,
"work_item_id": WORK_ITEM_ID,
"formal_compare_types": ["total_price"],
},
source_activation_func=activate,
source_rollback_func=rollback,