online-judge icon indicating copy to clipboard operation
online-judge copied to clipboard

Implement user reputation

Open Ninjaclasher opened this issue 5 years ago • 6 comments
trafficstars

Closes #839.

Ninjaclasher avatar May 11 '20 04:05 Ninjaclasher

Reputation is calculated as follows:

  1. Take the latest DMOJ_REPUTATION_ENTRIES (= 20) comment scores by the user.
  2. The latest comment is weighted 1, the second weighted 0.98 ... nth comment is weighted 0.98 ^ n (similar to PP calculation)
  3. Each comment's weight is multiplied by f(comment's score), where f is DMOJ_REPUTATION_FUNCTION (denote as the comment's "value")
  4. 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).

Ninjaclasher avatar May 11 '20 16:05 Ninjaclasher

Desmos graph of the default function: image

Ninjaclasher avatar May 11 '20 17:05 Ninjaclasher

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?

kiritofeng avatar May 24 '20 00:05 kiritofeng

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.

Ninjaclasher avatar May 24 '20 03:05 Ninjaclasher

I've updated this PR to include hidden comment scores in the reputation calculation.

Ninjaclasher avatar Oct 18 '20 21:10 Ninjaclasher

Codecov Report

Merging #1384 into master will decrease coverage by 0.00%. The diff coverage is 42.55%.

Impacted file tree graph

@@            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 data Powered by Codecov. Last update 488c14a...7fad0d2. Read the comment docs.

codecov-io avatar Oct 18 '20 21:10 codecov-io