From db04bfce94bd690c1163b28f849c825983b8074f Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 26 Sep 2018 14:54:06 -0600 Subject: [PATCH] Make exemplary "activate" at 0.5 weight Since the production version is using a default label weight of 0.5, previously two users would have had to label the same comment Exemplary for it to actually activate. This will probably be fairly uncommon so we most likely don't want it to work that way. This reduces it to 0.5 so that one label will trigger it, but it would probably be better to specifically set it to the default label weight if that's feasible somehow. --- tildes/tildes/models/comment/comment.py | 10 ++++++++-- tildes/tildes/models/comment/comment_tree.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tildes/tildes/models/comment/comment.py b/tildes/tildes/models/comment/comment.py index 0685408..a4f52f2 100644 --- a/tildes/tildes/models/comment/comment.py +++ b/tildes/tildes/models/comment/comment.py @@ -259,8 +259,14 @@ class Comment(DatabaseModel): """Return whether a label has been applied enough to be considered "active".""" label_weight = self.label_weights[label_name] - # all labels must have at least 1.0 weight - if label_weight < 1.0: + # Exemplary labels become "active" at 0.5 weight, all others at 1.0 + # Would be best to use the default_user_comment_label_weight value if possible + if label_name == "exemplary": + min_weight = 0.5 + else: + min_weight = 1.0 + + if label_weight < min_weight: return False # for "noise", weight must be more than 1/5 of the vote count (5 votes diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index 89fb711..7e8d98a 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -292,7 +292,7 @@ class CommentInTree(ObjectProxy): return (self.num_votes // 2,) # Exemplary comments add 1.0 to the the total weight of the exemplary labels, - # and multiply the vote count by that. Minimum (weight 1.0), votes are doubled. + # and multiply the vote count by that. For example, weight 1.0 = votes doubled. if self.is_label_active("exemplary"): multiplier = self.label_weights["exemplary"] + 1.0 return (round(multiplier * self.num_votes),)