feat(pugongying): 将粉丝年龄分布拆分为独立列导出

将 fansProfile.ages 从单个汇总字段拆分为 5 个独立年龄段列
(<18、18-24、25-34、35-44、>44),每列对应该年龄段的粉丝占比。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
wxs 2026-03-13 19:54:08 +08:00
parent 33d6aeb495
commit 0875e20a89

View File

@ -31,7 +31,11 @@
const FIELD_LABEL_MAP = {
id: "ID",
fansProfile: "粉丝画像",
"fansProfile.ages": "粉丝年龄分布",
"fansProfile.ages.<18": "18岁以下粉丝占比",
"fansProfile.ages.18-24": "18-24岁粉丝占比",
"fansProfile.ages.25-34": "25-34岁粉丝占比",
"fansProfile.ages.35-44": "35-44岁粉丝占比",
"fansProfile.ages.>44": "44岁以上粉丝占比",
"fansProfile.gender.male": "粉丝男性占比",
"fansProfile.gender.female": "粉丝女性占比",
userId: "达人ID",
@ -142,7 +146,19 @@
const value = record[key];
if (Array.isArray(value)) {
baseTarget[nextPath] = summarizeArray(value);
if (
value.length &&
value.every(
(item) =>
isPlainObject(item) && "group" in item && "percent" in item,
)
) {
for (const item of value) {
baseTarget[`${nextPath}.${item.group}`] = item.percent;
}
} else {
baseTarget[nextPath] = summarizeArray(value);
}
continue;
}