Permalink
Browse files

add limit for user reputation change

  • Loading branch information...
1 parent ecd3b89 commit e4f1d095034857028223b9b4e3e0f0ef5a993ea8 lepture committed Mar 22, 2012
Showing with 10 additions and 4 deletions.
  1. +3 −0 june/app.py
  2. +6 −3 june/handlers/api.py
  3. +1 −1 june/models/__init__.py
View
@@ -54,6 +54,9 @@
define('down_factor_for_user', 1)
define('vote_reply_factor_for_topic', 500)
define('vote_reply_factor_for_user', 1)
+define('up_max_for_user', 10)
+define('down_max_for_user', 4)
+define('vote_max_for_user', 4)
# third party support config
define('gravatar_base_url', "http://www.gravatar.com/avatar/")
View
@@ -63,7 +63,8 @@ def _calc_user_impact(self):
if self.current_user.reputation < 2:
return 0
factor = int(options.up_factor_for_user)
- return factor * int(math.log(self.current_user.reputation))
+ impact = factor * int(math.log(self.current_user.reputation))
+ return min(impact, options.up_max_for_user)
class DownTopicHandler(BaseHandler):
@@ -125,7 +126,8 @@ def _calc_user_impact(self):
if self.current_user.reputation < 2:
return 0
factor = int(options.down_factor_for_user)
- return factor * int(math.log(self.current_user.reputation))
+ impact = factor * int(math.log(self.current_user.reputation))
+ return min(impact, options.down_max_for_user)
class VoteReplyHandler(BaseHandler):
@@ -152,7 +154,8 @@ def _calc_user_impact(self):
if self.current_user.reputation < 2:
return 0
factor = int(options.vote_reply_factor_for_user)
- return factor * int(math.log(self.current_user.reputation))
+ impact = factor * int(math.log(self.current_user.reputation))
+ return min(impact, options.vote_max_for_user)
class UpReplyHandler(VoteReplyHandler):
View
@@ -65,7 +65,7 @@ class Member(db.Model):
website = Column(String(400))
role = Column(Integer, default=2)
- reputation = Column(Integer, default=10)
+ reputation = Column(Integer, default=20)
token = Column(String(16))
created = Column(DateTime, default=datetime.utcnow)
last_notify = Column(DateTime, default=datetime.utcnow)

0 comments on commit e4f1d09

Please sign in to comment.