online-judge
online-judge copied to clipboard
Implement user reputation
Closes #839.
Reputation is calculated as follows:
- Take the latest
DMOJ_REPUTATION_ENTRIES(= 20) comment scores by the user. - The latest comment is weighted 1, the second weighted 0.98 ... nth comment is weighted 0.98 ^ n (similar to PP calculation)
- Each comment's weight is multiplied by
f(comment's score), wherefisDMOJ_REPUTATION_FUNCTION(denote as the comment's "value") - The sum of the comment values is the user's reputation.
By default, DMOJ_REPUTATION_FUNCTION is the product of a sigmoid-like function (tanh) and the natural logarithm of the comment's score (slightly rescaled).
This is done to combat users who vote for their own comments (<= 4 votes increases reputation very little, >= 4 and <= 16 votes increases reputation a lot, >= 16 votes increases reputation at a logarithmic rate).
Desmos graph of the default function:

Code looks good. However, I don't know if the correct behaviour is boosting the user's reputation if we hide disruptive posts.
What if we apply a penalty for hidden posts?
I think maybe it's better to just include hidden comment scores into the reputation calculation as well.
The issue with applying a penalty to hidden posts is if a user posts a bad comment and someone replies to that comment with a good comment (e.g a moderator). Now if the first comment gets hidden, both users would be punished since hiding a comment hides all descendant comments as well.
I've updated this PR to include hidden comment scores in the reputation calculation.
Codecov Report
Merging #1384 into master will decrease coverage by
0.00%. The diff coverage is42.55%.
@@ Coverage Diff @@
## master #1384 +/- ##
==========================================
- Coverage 46.05% 46.04% -0.01%
==========================================
Files 213 214 +1
Lines 12145 12190 +45
==========================================
+ Hits 5593 5613 +20
- Misses 6552 6577 +25
| Impacted Files | Coverage Δ | |
|---|---|---|
| judge/admin/comments.py | 66.66% <0.00%> (-4.77%) |
:arrow_down: |
| judge/comments.py | 40.00% <0.00%> (-0.87%) |
:arrow_down: |
| judge/views/api/api_v1.py | 23.18% <ø> (ø) |
|
| judge/views/api/api_v2.py | 47.46% <ø> (ø) |
|
| judge/views/comment.py | 38.51% <0.00%> (-1.18%) |
:arrow_down: |
| dmoj/settings.py | 94.38% <33.33%> (-3.26%) |
:arrow_down: |
| judge/models/profile.py | 89.77% <36.36%> (-3.57%) |
:arrow_down: |
| judge/migrations/0114_user_reputation.py | 81.25% <81.25%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 488c14a...7fad0d2. Read the comment docs.