gongxiangp2/lib/value-metrics.ts
2026-09-07 12:20:03 +08:00

40 lines
894 B
TypeScript

export type ValueMetricsTypeSummary = {
key: string
label: string
totalCount: number
reusedCount: number
reuseRate: number | null
}
export type ValueMetricsMaterial = {
id: string
title: string
materialType: string
authorName: string
createdAt: string
downloadCount: number
categoryName: string
sceneName: string
platformName: string
}
export type ValueMetricsInsights = {
types: ValueMetricsTypeSummary[]
selectedType: string | null
selectedTypeSummary: ValueMetricsTypeSummary | null
materials: ValueMetricsMaterial[]
materialsTotal: number
hasMore: boolean
summary: {
totalAssets: number
reusedAssets: number
reuseRate: number | null
}
}
export function calculateReuseRate(reusedCount: number, totalCount: number): number | null {
if (totalCount <= 0) return null
return Number(((reusedCount / totalCount) * 100).toFixed(1))
}