Skip to content

Commit

Permalink
make upvote extra percentage configurable in the ACP
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBronx committed Sep 12, 2015
1 parent ee9a2b3 commit 66064d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var MIN_POSTS_TO_UPVOTE = 20,
MIN_REPUTATION_TO_DOWNVOTE = 10,
MAX_VOTES_PER_USER_AND_THREAD = 5,
MAX_VOTES_TO_SAME_USER_PER_MONTH = 1,
UPVOTE_EXTRA_PERCENTAGE = 5,
REP_LOG_NAMESPACE = "reputationLog",
DISABLED_CATEGORIES_IDS = [];

Expand Down Expand Up @@ -41,6 +42,9 @@ var Config = {
}
return calculatedVotesPerUser;
},
upvoteExtraPercentage: function() {
return UPVOTE_EXTRA_PERCENTAGE;
},
getMainLogId: function(voterId, authorId, topicId, postId) {
return REP_LOG_NAMESPACE + ":"
+ voterId + ":"
Expand Down Expand Up @@ -73,6 +77,7 @@ var Config = {
settings.minReputationToDownvote = MIN_REPUTATION_TO_DOWNVOTE;
settings.maxVotesPerUserInThread = MAX_VOTES_PER_USER_AND_THREAD;
settings.maxVotesToSameUserInMonth = MAX_VOTES_TO_SAME_USER_PER_MONTH;
settings.upvoteExtraPercentage = UPVOTE_EXTRA_PERCENTAGE;
settings.disabledCategoriesIds = DISABLED_CATEGORIES_IDS;
settings.repLogNamespace = REP_LOG_NAMESPACE;
return settings;
Expand All @@ -85,6 +90,7 @@ var Config = {
MIN_REPUTATION_TO_DOWNVOTE = settings.minReputationToDownvote;
MAX_VOTES_PER_USER_AND_THREAD = settings.maxVotesPerUserInThread;
MAX_VOTES_TO_SAME_USER_PER_MONTH = settings.maxVotesToSameUserInMonth;
UPVOTE_EXTRA_PERCENTAGE = settings.upvoteExtraPercentage;
DISABLED_CATEGORIES_IDS = intArray(settings.disabledCategoriesIds);
}
};
Expand Down
3 changes: 2 additions & 1 deletion ReputationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var ReputationManager = function(Config) {
};

this.calculateUpvoteWeight = function(user) {
var weight = Math.floor(user.reputation/10);
var extraRate = Config.upvoteExtraPercentage()/100;
var weight = Math.floor(user.reputation * extraRate);
if (weight<0) weight = 0;
return weight;
};
Expand Down
5 changes: 5 additions & 0 deletions public/templates/admin/plugins/reputation-rules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<label>Minimum amount of days since registration to upvote:</label>
<input class="form-control" type="number" data-key="minDaysToUpvote" title="Minimum days to upvote">
</div>
<!-- (UPVOTE_EXTRA_PERCENTAGE) -->
<div class="col-xs-12 col-md-6 form-group">
<label>Percentage of voter's reputation that is added as extra (this extra is not subtracted from voter!):</label>
<input class="form-control" type="number" data-key="upvoteExtraPercentage" title="Upvote extra reputation">
</div>
</div>
<div class="clearfix"></div>
<h3>Downvoting</h3>
Expand Down

0 comments on commit 66064d6

Please sign in to comment.