Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-07-06 18:01:34 +03:00
parent 1448dab9d7
commit 289f204752
3 changed files with 72 additions and 6 deletions
@@ -3707,8 +3707,8 @@ function productScore100 ({ suffix = '90d', salesUSD = 0, margin = 0, stockTurno
0.30 * marginScore(margin) +
0.20 * ratioScore(stockTurnover, stockTurnoverTarget(suffix)) +
0.20 * revenue +
0.15 * ratioScore(marketCount, 8) +
0.15 * ratioScore(customerCount, 25)
0.15 * ratioScore(marketCount, marketSpreadTarget(suffix)) +
0.15 * ratioScore(customerCount, customerSpreadTarget(suffix))
)
}
@@ -3775,6 +3775,20 @@ function stockTurnoverTarget () {
return 4
}
function marketSpreadTarget (suffix) {
if (suffix === '90d') return 3
if (suffix === '180d') return 5
if (suffix === '365d') return 6
return 8
}
function customerSpreadTarget (suffix) {
if (suffix === '90d') return 8
if (suffix === '180d') return 15
if (suffix === '365d') return 18
return 25
}
function periodCount (row, prefix, suffix) {
const keyed = Number(row?.[`${prefix}_${suffix}`] || 0)
if (keyed > 0) return keyed