Browse Source

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.
merge-requests/40/head
Deimos 6 years ago
parent
commit
db04bfce94
  1. 10
      tildes/tildes/models/comment/comment.py
  2. 2
      tildes/tildes/models/comment/comment_tree.py

10
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

2
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),)

Loading…
Cancel
Save