Created
December 3, 2017 15:00
-
-
Save 48klocs/1e4e06afc3335284327949b6ad8e7932 to your computer and use it in GitHub Desktop.
Tweaked rating formula
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
| _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