fix databi registration country metric
This commit is contained in:
parent
05412e477a
commit
889e75f6a1
@ -18,7 +18,7 @@ const defaultSortByTab = {
|
|||||||
|
|
||||||
const countryColumns = [
|
const countryColumns = [
|
||||||
{ key: "country", label: "国家", type: "text", align: "left" },
|
{ key: "country", label: "国家", type: "text", align: "left" },
|
||||||
{ key: "visitors", label: "访客" },
|
{ key: "registrations", label: "注册" },
|
||||||
{ key: "active_users", label: "活跃用户" },
|
{ key: "active_users", label: "活跃用户" },
|
||||||
{ key: "paid_users", label: "付费用户" },
|
{ key: "paid_users", label: "付费用户" },
|
||||||
{ key: "recharge_users", label: "充值用户" },
|
{ key: "recharge_users", label: "充值用户" },
|
||||||
@ -44,8 +44,8 @@ const countrySortAccessors = {
|
|||||||
recharge_conversion_rate: (item) => item.recharge_conversion_rate,
|
recharge_conversion_rate: (item) => item.recharge_conversion_rate,
|
||||||
recharge_users: (item) => item.recharge_users,
|
recharge_users: (item) => item.recharge_users,
|
||||||
recharge_usd_minor: (item) => item.recharge_usd_minor,
|
recharge_usd_minor: (item) => item.recharge_usd_minor,
|
||||||
trend_rate: (item) => item.trend_rate,
|
registrations: (item) => item.registrations,
|
||||||
visitors: (item) => item.visitors
|
trend_rate: (item) => item.trend_rate
|
||||||
};
|
};
|
||||||
|
|
||||||
const giftColumns = [
|
const giftColumns = [
|
||||||
@ -146,7 +146,7 @@ function CountryTable({ items, loading, onSort, sortState }) {
|
|||||||
<tr key={item.country}>
|
<tr key={item.country}>
|
||||||
<td>{index + 1}</td>
|
<td>{index + 1}</td>
|
||||||
<td>{item.flag ? <i className="table-flag">{item.flag}</i> : null}{item.country}</td>
|
<td>{item.flag ? <i className="table-flag">{item.flag}</i> : null}{item.country}</td>
|
||||||
<td>{formatNumber(item.visitors)}</td>
|
<td>{formatNumber(item.registrations)}</td>
|
||||||
<td>{formatNumber(item.active_users)}</td>
|
<td>{formatNumber(item.active_users)}</td>
|
||||||
<td>{formatNumber(item.paid_users)}</td>
|
<td>{formatNumber(item.paid_users)}</td>
|
||||||
<td>{formatNumber(item.recharge_users)}</td>
|
<td>{formatNumber(item.recharge_users)}</td>
|
||||||
|
|||||||
@ -8,19 +8,19 @@ const countryItems = [
|
|||||||
country: "阿富汗",
|
country: "阿富汗",
|
||||||
flag: "🇦🇫",
|
flag: "🇦🇫",
|
||||||
recharge_usd_minor: 50000,
|
recharge_usd_minor: 50000,
|
||||||
visitors: 10
|
registrations: 10
|
||||||
}),
|
}),
|
||||||
createCountryRow({
|
createCountryRow({
|
||||||
country: "巴西",
|
country: "巴西",
|
||||||
flag: "🇧🇷",
|
flag: "🇧🇷",
|
||||||
recharge_usd_minor: 10000,
|
recharge_usd_minor: 10000,
|
||||||
visitors: 30
|
registrations: 30
|
||||||
}),
|
}),
|
||||||
createCountryRow({
|
createCountryRow({
|
||||||
country: "中国",
|
country: "中国",
|
||||||
flag: "🇨🇳",
|
flag: "🇨🇳",
|
||||||
recharge_usd_minor: 30000,
|
recharge_usd_minor: 30000,
|
||||||
visitors: 20
|
registrations: 20
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ test("sorts country table headers ascending and descending", async () => {
|
|||||||
|
|
||||||
expect(firstCountryCell()).toHaveTextContent("阿富汗");
|
expect(firstCountryCell()).toHaveTextContent("阿富汗");
|
||||||
|
|
||||||
await user.click(screen.getByRole("button", { name: /访客/ }));
|
await user.click(screen.getByRole("button", { name: /注册/ }));
|
||||||
|
|
||||||
expect(screen.getByRole("columnheader", { name: /访客/ })).toHaveAttribute("aria-sort", "descending");
|
expect(screen.getByRole("columnheader", { name: /注册/ })).toHaveAttribute("aria-sort", "descending");
|
||||||
expect(firstCountryCell()).toHaveTextContent("巴西");
|
expect(firstCountryCell()).toHaveTextContent("巴西");
|
||||||
|
|
||||||
await user.click(screen.getByRole("button", { name: /访客/ }));
|
await user.click(screen.getByRole("button", { name: /注册/ }));
|
||||||
|
|
||||||
expect(screen.getByRole("columnheader", { name: /访客/ })).toHaveAttribute("aria-sort", "ascending");
|
expect(screen.getByRole("columnheader", { name: /注册/ })).toHaveAttribute("aria-sort", "ascending");
|
||||||
expect(firstCountryCell()).toHaveTextContent("阿富汗");
|
expect(firstCountryCell()).toHaveTextContent("阿富汗");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ function createCountryRow(overrides) {
|
|||||||
recharge_conversion_rate: 0,
|
recharge_conversion_rate: 0,
|
||||||
recharge_users: 0,
|
recharge_users: 0,
|
||||||
recharge_usd_minor: 0,
|
recharge_usd_minor: 0,
|
||||||
|
registrations: 0,
|
||||||
trend_rate: 0,
|
trend_rate: 0,
|
||||||
visitors: 0,
|
|
||||||
...overrides
|
...overrides
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function createDashboardModel(overview, { appCode, countryId, range, time
|
|||||||
const activeUsers = readNumber(source, "active_users", "activeUsers");
|
const activeUsers = readNumber(source, "active_users", "activeUsers");
|
||||||
const paidUsers = readNumber(source, "paid_users", "paidUsers");
|
const paidUsers = readNumber(source, "paid_users", "paidUsers");
|
||||||
const rechargeUsers = readNumber(source, "recharge_users", "rechargeUsers", "paid_users", "paidUsers");
|
const rechargeUsers = readNumber(source, "recharge_users", "rechargeUsers", "paid_users", "paidUsers");
|
||||||
const newUsers = readNumber(source, "new_users", "newUsers", "visitors");
|
const newUsers = readNumber(source, "new_users", "newUsers", "registrations", "registered_users", "registeredUsers");
|
||||||
const arpu = readNumber(source, "arpu_usd_minor", "arpuUsdMinor");
|
const arpu = readNumber(source, "arpu_usd_minor", "arpuUsdMinor");
|
||||||
const arppu = readNumber(source, "arppu_usd_minor", "arppuUsdMinor");
|
const arppu = readNumber(source, "arppu_usd_minor", "arppuUsdMinor");
|
||||||
const giftCoinSpent = readNumber(source, "gift_coin_spent", "giftCoinSpent");
|
const giftCoinSpent = readNumber(source, "gift_coin_spent", "giftCoinSpent");
|
||||||
@ -257,8 +257,8 @@ function normalizeCountryRow(item, index, totalRecharge) {
|
|||||||
: ratio(rechargeUsers, activeUsers),
|
: ratio(rechargeUsers, activeUsers),
|
||||||
recharge_users: rechargeUsers,
|
recharge_users: rechargeUsers,
|
||||||
share: recharge / totalRecharge,
|
share: recharge / totalRecharge,
|
||||||
trend_rate: numberValue(item.trend_rate ?? item.trendRate),
|
registrations: numberValue(item.new_users ?? item.newUsers ?? item.registrations ?? item.registered_users ?? item.registeredUsers),
|
||||||
visitors: numberValue(item.visitors ?? item.new_users ?? item.newUsers)
|
trend_rate: numberValue(item.trend_rate ?? item.trendRate)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,6 +107,23 @@ test("uses active users as payer and recharge conversion denominator", () => {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("uses registration count instead of legacy visitors in country breakdown", () => {
|
||||||
|
const model = createDashboardModel({
|
||||||
|
country_breakdown: [
|
||||||
|
{
|
||||||
|
country: "菲律宾",
|
||||||
|
new_users: 12,
|
||||||
|
visitors: 99
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, { appCode: "lalu", countryId: 0, range: { end: "2026-06-04", start: "2026-06-04" } });
|
||||||
|
|
||||||
|
expect(model.countryBreakdown[0]).toEqual(expect.objectContaining({
|
||||||
|
registrations: 12
|
||||||
|
}));
|
||||||
|
expect(model.countryBreakdown[0]).not.toHaveProperty("visitors");
|
||||||
|
});
|
||||||
|
|
||||||
function metricValue(model, label) {
|
function metricValue(model, label) {
|
||||||
return [...model.kpis, ...model.businessKpis, ...model.robotGiftKpis].find((item) => item.label === label)?.value;
|
return [...model.kpis, ...model.businessKpis, ...model.robotGiftKpis].find((item) => item.label === label)?.value;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user