fix: always show all 9 soft factors in score breakdown
Previously factors with weight=0 (e.g. Steuerlast for Innovatech) were invisible. Now all 9 factors appear in allSoftFactors; only weighted ones contribute to the score calculation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -362,11 +362,12 @@ export function calculateScore(need: Need, property: Property): MatchEngineOutpu
|
|||||||
const hardMatchScore = hardWeightSum > 0 ? Math.min(100, Math.round(hardRaw / hardWeightSum)) : 0
|
const hardMatchScore = hardWeightSum > 0 ? Math.min(100, Math.round(hardRaw / hardWeightSum)) : 0
|
||||||
|
|
||||||
// ── Soft factor scoring ────────────────────────────────────────────────────
|
// ── Soft factor scoring ────────────────────────────────────────────────────
|
||||||
const softFactors: ScoreFactor[] = SOFT_FACTOR_KEYS
|
// All 9 factors always included in output so breakdown is always complete.
|
||||||
.filter(k => (profile[k] ?? 0) > 0)
|
// Only weighted factors (weight > 0) contribute to the score calculation.
|
||||||
.map(k => scoreSoftFactor(k, profile[k], property))
|
const allSoftDisplay: ScoreFactor[] = SOFT_FACTOR_KEYS
|
||||||
|
.map(k => scoreSoftFactor(k, profile[k] ?? 0, property))
|
||||||
const softWeightSum = SOFT_FACTOR_KEYS.reduce((s, k) => s + (profile[k] ?? 0), 0)
|
const softWeightSum = SOFT_FACTOR_KEYS.reduce((s, k) => s + (profile[k] ?? 0), 0)
|
||||||
const softRaw = softFactors.reduce((s, f) => s + f.contribution, 0)
|
const softRaw = allSoftDisplay.filter(f => f.weight > 0).reduce((s, f) => s + f.contribution, 0)
|
||||||
const softFactorScore = softWeightSum > 0 ? Math.min(100, Math.round(softRaw / softWeightSum)) : 50
|
const softFactorScore = softWeightSum > 0 ? Math.min(100, Math.round(softRaw / softWeightSum)) : 50
|
||||||
|
|
||||||
// ── Modifiers ──────────────────────────────────────────────────────────────
|
// ── Modifiers ──────────────────────────────────────────────────────────────
|
||||||
@@ -379,8 +380,9 @@ export function calculateScore(need: Need, property: Property): MatchEngineOutpu
|
|||||||
const rawFinal = baseScore + dqMod + confMod - hardFilter.severePenalty
|
const rawFinal = baseScore + dqMod + confMod - hardFilter.severePenalty
|
||||||
const finalScore = Math.round(Math.min(100, Math.max(0, rawFinal)))
|
const finalScore = Math.round(Math.min(100, Math.max(0, rawFinal)))
|
||||||
|
|
||||||
// ── Factor classification ──────────────────────────────────────────────────
|
// ── Factor classification — only use weighted soft factors for positive/negative ──
|
||||||
const allFactors = [...hardFactors, ...softFactors]
|
const weightedSoftFactors = allSoftDisplay.filter(f => f.weight > 0)
|
||||||
|
const allFactors = [...hardFactors, ...weightedSoftFactors]
|
||||||
const THRESHOLD_POSITIVE = 70
|
const THRESHOLD_POSITIVE = 70
|
||||||
const THRESHOLD_NEGATIVE = 45
|
const THRESHOLD_NEGATIVE = 45
|
||||||
const positiveFactors = allFactors
|
const positiveFactors = allFactors
|
||||||
@@ -392,7 +394,7 @@ export function calculateScore(need: Need, property: Property): MatchEngineOutpu
|
|||||||
.sort((a, b) => a.contribution - b.contribution)
|
.sort((a, b) => a.contribution - b.contribution)
|
||||||
.slice(0, 4)
|
.slice(0, 4)
|
||||||
|
|
||||||
const tradeOffs = analyzeTradeOffs(hardFactors, softFactors, need, property)
|
const tradeOffs = analyzeTradeOffs(hardFactors, weightedSoftFactors, need, property)
|
||||||
const risks = analyzeRisks(property, hardFactors)
|
const risks = analyzeRisks(property, hardFactors)
|
||||||
const missingData = identifyMissingData(property, need)
|
const missingData = identifyMissingData(property, need)
|
||||||
|
|
||||||
@@ -408,7 +410,7 @@ export function calculateScore(need: Need, property: Property): MatchEngineOutpu
|
|||||||
positiveFactors,
|
positiveFactors,
|
||||||
negativeFactors,
|
negativeFactors,
|
||||||
allHardFactors: hardFactors,
|
allHardFactors: hardFactors,
|
||||||
allSoftFactors: softFactors,
|
allSoftFactors: allSoftDisplay,
|
||||||
tradeOffs,
|
tradeOffs,
|
||||||
risks,
|
risks,
|
||||||
missingData,
|
missingData,
|
||||||
|
|||||||
Reference in New Issue
Block a user