Created
March 24, 2020 15:12
-
-
Save andre487/27dc9820e77cdc85adaff09a1800c8fe to your computer and use it in GitHub Desktop.
Velocity Voting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const weights = { | |
fcp: 2, | |
fmp: 5, | |
js: 3, | |
tti: 1 | |
} | |
const negativeWeights = { | |
fcp: 3, | |
fmp: 6, | |
js: 4, | |
tti: 0 | |
} | |
function isRequestGood(rumGrades) { | |
let goodVotes = 0 | |
let badVotes = 0 | |
for (const [metricName, metricGrade] of Object.entries(rumGrades)) { | |
const weight = weights[metricName] | |
const negativeWeight = negativeWeights[metricName] | |
switch (metricGrade) { | |
case 'instant': | |
goodVotes += weight * 2 | |
break; | |
case 'fast': | |
goodVotes += weight * 1.5 | |
break; | |
case 'tolerantly': | |
goodVotes += weight | |
break; | |
case 'slow': | |
badVotes += negativeWeight; | |
break; | |
case 'terrible': | |
badVotes += negativeWeight * 3; | |
break; | |
} | |
} | |
return goodVotes > badVotes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment