feat: show Adpingid in order coverage
This commit is contained in:
+20
-2
@@ -17,7 +17,7 @@ DEFAULT_SOURCE = Path(
|
||||
"/Users/wangyuan/Documents/SHAREit/运营/TaurusX搬单/武汉自投投放下单_AM&Media Buy.xlsx"
|
||||
)
|
||||
TARGET_PLATFORM = "TaurusxDSP"
|
||||
REQUIRED_COLUMNS = {"状态", "PromotionAppName", "pkg", "投放平台", "投放国家"}
|
||||
REQUIRED_COLUMNS = {"状态", "Adpingid", "PromotionAppName", "pkg", "投放平台", "投放国家"}
|
||||
|
||||
PLATFORM_ALIASES = {
|
||||
"mtg": "MTG",
|
||||
@@ -74,6 +74,13 @@ def normalize_status(value: Any) -> str:
|
||||
return "其他/不可投"
|
||||
|
||||
|
||||
def sort_adpingids(values: set[str]) -> list[str]:
|
||||
def sort_key(value: str) -> tuple[int, int | str]:
|
||||
return (0, int(value)) if value.isdigit() else (1, value.casefold())
|
||||
|
||||
return sorted(values, key=sort_key)
|
||||
|
||||
|
||||
def parse_workbook(source: Path) -> tuple[list[dict[str, str]], dict[str, int]]:
|
||||
if not source.is_file():
|
||||
raise FileNotFoundError(f"Workbook not found: {source}")
|
||||
@@ -103,6 +110,7 @@ def parse_workbook(source: Path) -> tuple[list[dict[str, str]], dict[str, int]]:
|
||||
counters["excluded_examples"] += 1
|
||||
continue
|
||||
|
||||
adpingid = clean_text(row[indexes["Adpingid"]])
|
||||
product = clean_text(row[indexes["PromotionAppName"]])
|
||||
pkg = clean_text(row[indexes["pkg"]])
|
||||
country = clean_text(row[indexes["投放国家"]]).upper()
|
||||
@@ -116,6 +124,7 @@ def parse_workbook(source: Path) -> tuple[list[dict[str, str]], dict[str, int]]:
|
||||
|
||||
records.append(
|
||||
{
|
||||
"adpingid": adpingid,
|
||||
"product": product or "未命名产品",
|
||||
"pkg": pkg,
|
||||
"country": country,
|
||||
@@ -139,13 +148,20 @@ def aggregate(records: list[dict[str, str]], counters: dict[str, int], source: P
|
||||
"pkg": row["pkg"],
|
||||
"country": row["country"],
|
||||
"products": set(),
|
||||
"platforms": defaultdict(lambda: {"statuses": Counter(), "order_count": 0}),
|
||||
"adpingids": set(),
|
||||
"platforms": defaultdict(
|
||||
lambda: {"statuses": Counter(), "adpingids": set(), "order_count": 0}
|
||||
),
|
||||
"order_count": 0,
|
||||
},
|
||||
)
|
||||
group["products"].add(row["product"])
|
||||
if row["adpingid"]:
|
||||
group["adpingids"].add(row["adpingid"])
|
||||
detail = group["platforms"][row["platform"]]
|
||||
detail["statuses"][row["status"]] += 1
|
||||
if row["adpingid"]:
|
||||
detail["adpingids"].add(row["adpingid"])
|
||||
detail["order_count"] += 1
|
||||
group["order_count"] += 1
|
||||
|
||||
@@ -160,12 +176,14 @@ def aggregate(records: list[dict[str, str]], counters: dict[str, int], source: P
|
||||
platform_details.append(
|
||||
{
|
||||
"platform": name,
|
||||
"adpingids": sort_adpingids(detail["adpingids"]),
|
||||
"statuses": dict(sorted(detail["statuses"].items())),
|
||||
"order_count": detail["order_count"],
|
||||
}
|
||||
)
|
||||
output_records.append(
|
||||
{
|
||||
"adpingids": sort_adpingids(group["adpingids"]),
|
||||
"product": " / ".join(sorted(group["products"])),
|
||||
"pkg": group["pkg"],
|
||||
"country": group["country"],
|
||||
|
||||
Reference in New Issue
Block a user