I have an application where users can:
- Write reviews about products
- Add comments to products
- Up / Down vote reviews
- Up / Down vote comments
Every Up/Down vote is recorded in a db table.
What i want to do now is to create a ranking of the most active users in the last 4 weeks. Of course good reviews should be weighted more than good comments. But also e.g. 10 good comments should be weighted more than just one good review.
Example:
// reviews created in recent 4 weeks
//format: [ upVoteCount, downVoteCount ]
var reviews = [ [120,23], [32,12], [12,0], [23,45] ];
// comments created in recent 4 weeks
// format: [ upVoteCount, downVoteCount ]
var comments = [ [1,2], [322,1], [0,0], [0,45] ];
// create weight vector
// format: [ reviewWeight, commentsWeight ]
var weight = [0.60, 0.40];
// signature: activties..., activityWeight
var userActivityScore = score(reviews, comments, weight);
... update user table ...
List<Users> users = "from users u order by u.userActivityScore desc";
How would a fair scoring function look like?
How could an implementation of the score()
function look like? How to add a weight g
to the function so that reviews are weighted heavier? How would such a function look like if, for example, votes for pictures would be added?