Created
June 14, 2011 00:08
-
-
Save wedtm/1024062 to your computer and use it in GitHub Desktop.
MCSL Ranking Algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rank = 10 #Starting Ranking | |
| # Subtract 1 if the server was made less than 7 days ago, prevents new servers from being at the top. | |
| if self.created_at > 7.days.ago | |
| rank = rank - 1 | |
| end | |
| # If the last check failed, drop the ranking significantly, this is to give a temporary, but severe penalty | |
| if self.uptime_checks.last.result == false | |
| rank = rank - 50 | |
| end | |
| good = 0 | |
| last_month = self.uptime_checks.where(:created_at.gt => 1.month.ago) | |
| last_month.each do |check| | |
| good = good + 1 if check.result = true | |
| end | |
| count = 0 | |
| good.times do | |
| case count | |
| when 0...24 | |
| rank = rank + 0.1 | |
| when 25...150 | |
| rank = rank + 0.015 | |
| when 150...750 | |
| rank = rank + 0.005 | |
| end | |
| count = count + 1 | |
| end | |
| # Now we multiply all this by the uptime percentage | |
| rank = rank * percentage | |
| if self.premium? | |
| rank = rank * 1.1 | |
| end | |
| return rank |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment