fix: format business ability estimates
This commit is contained in:
@@ -158,19 +158,19 @@ export function mapBusinessAbilityEstimateResponse(
|
||||
return {
|
||||
oneToTwenty: {
|
||||
expectedCpe: formatDecimal(readNumber(data?.cpe_1_20), 1),
|
||||
expectedCpm: formatDecimal(readNumber(data?.cpm_1_20), 0),
|
||||
expectedCpm: formatFixedDecimal(readNumber(data?.cpm_1_20), 1),
|
||||
expectedPlay,
|
||||
hotRate
|
||||
},
|
||||
overSixty: {
|
||||
expectedCpe: formatDecimal(readNumber(data?.cpe_60), 1),
|
||||
expectedCpm: formatDecimal(readNumber(data?.cpm_60), 0),
|
||||
expectedCpm: formatFixedDecimal(readNumber(data?.cpm_60), 1),
|
||||
expectedPlay,
|
||||
hotRate
|
||||
},
|
||||
twentyToSixty: {
|
||||
expectedCpe: formatDecimal(readNumber(data?.cpe_20_60), 1),
|
||||
expectedCpm: formatDecimal(readNumber(data?.cpm_20_60), 0),
|
||||
expectedCpm: formatFixedDecimal(readNumber(data?.cpm_20_60), 1),
|
||||
expectedPlay,
|
||||
hotRate
|
||||
}
|
||||
@@ -203,7 +203,7 @@ function formatBasisPointRate(value: number | null): string {
|
||||
|
||||
function formatDecimalRate(value: number | null): string {
|
||||
if (value === null) {
|
||||
return "";
|
||||
return "缺失";
|
||||
}
|
||||
|
||||
return `${formatDecimal(value * 100, 0)}%`;
|
||||
@@ -230,6 +230,14 @@ function formatDecimal(value: number | null, digits: number): string {
|
||||
return fixed.replace(/\.0+$/, "").replace(/(\.\d*?)0+$/, "$1");
|
||||
}
|
||||
|
||||
function formatFixedDecimal(value: number | null, digits: number): string {
|
||||
if (value === null || !Number.isFinite(value)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return value.toFixed(digits);
|
||||
}
|
||||
|
||||
function readNestedNumber(
|
||||
data: Record<string, unknown> | null,
|
||||
objectKey: string,
|
||||
|
||||
Reference in New Issue
Block a user