开发者

How to implement "top writers" table in Rails?

In my Rails 3 application users can write messages/posts in forum.

I would like to display to users "Top Writes" table, something like:

Alex - 14% (i.e. 14% of forum's content was written by Alex)
Greg - 13%
Natalie - 10%
Rachel - 8%
...
  1. Would you store the number of characters (probably excluding punctuation) in each message in a database along开发者_如何学JAVA with other message details (and update it when message edited) ?

  2. Would you store the number of characters that each user wrote along with other user details (and update this number once user adds / deletes / updates a message) ?

  3. Would you store the total number of characters in the database (i.e. the sum of all numbers from 2. ?

  4. Would you store the percentages that are going to be displayed (and update them accordingly) ?


I would focus on a metric that rewards good content, not just content. Stack Overflow is a good example of this --- you get rewarded when your peers value your content.

For your specific question:

  1. Add columns on each Message: content-length
  2. Add a column on each User: total-content-length
  3. When you save a new message, recaculate total-content-length for the user (sum of all message.content-length)

The percentage based table at that point is fairly simple

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜