On a website based on PHP and CodeIgniter, users can earn a reputation for doing things differently from Stack Overflow. Each time a reputation is awarded, a new record is created in the MySQL table with a user_idreward for the action and value of this group of points (for example, 10 reputation). At the same time, the field in the table is updated users reputation_total.
Since all this is pointless without a reference system, I want to show users their percentage rating among all users. For a full reputation, this seems simple enough. Say my user_id- 1138. Just count the number of users in the table userswith reputation_totalless than mine, count the total number of users and divide to find the percentage of users with a lower reputation than mine. This will be a user rating of 1138 percentiles, right? Easily!
But I also show the results of reputations for different periods of time - for example, earned over the past seven days, which is associated with querying the reputation table and summing up all my points received from a certain date. I would also like to show the percentile rank for different time intervals - for example, I can be the 11th percentile in general, but the 50th percentile this month and the 97th percentile today.
It seems that I will have to go through and find the total reputation values for all users for a given period of time, and then see where I get into this group, no? Isn't that awfully cumbersome? What is the best way to do this?
Many thanks.
source
share