joshmcarthur/Latter — Issue #1: Get rid of lots of Array#sorts
Author: joshmcarthur
Created: 2012-03-07 00:38:47+00:00
State: open

Currently the ranking sorting system is slowing down homepage rendering by a couple of seconds because:

1. The sort on all players sorts by the 'ranking' method on a player
2. The ranking is calculated by sorting all players by their winning percentage, and then finding the current players position in the array.

Instead, I would suggest another implementation:

* Add a 'ranking' field to the database table
* When calling `ranking`, try and return this value first, and only do the actual calculation if the field is blank
* Add a method to the challenge completion method to update both involved players' ranking