Skip to content

Instantly share code, notes, and snippets.

@48klocs
Created December 3, 2017 15:00
Show Gist options
  • Select an option

  • Save 48klocs/1e4e06afc3335284327949b6ad8e7932 to your computer and use it in GitHub Desktop.

Select an option

Save 48klocs/1e4e06afc3335284327949b6ad8e7932 to your computer and use it in GitHub Desktop.
Tweaked rating formula
_getDownvoteMultiplier(dtrRating) {
if (dtrRating.votes.total > 300) {
return 1.0;
}
if (dtrRating.votes.total > 200) {
return 1.5;
}
if (dtrRating.votes.total > 100) {
return 2.0;
}
return 2.5;
}
_getScore(dtrRating) {
const downvoteMultipler = this._getDownvoteMultiplier(dtrRating);
const rating = ((dtrRating.votes.total - (dtrRating.votes.downvotes * downvoteMultipler)) / dtrRating.votes.total) * 5;
if ((rating < 1) &&
(dtrRating.votes.total > 0)) {
return 1;
}
return rating;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment