Fix sort order on leaderboard

* Nulls were appearing first in the errors column
* Make them appear last
* That's it
Move data access to the controller

* index.html.erb was calling ActiveRecord directly
Remove ".0" from integer leaderboard numbers

* For some reason, Postgres gives us a floating point column for an integer sum.
  Be explicit that this is not supposed to be the case by casting to ::integer
  in the sum/count parts of the leaderboard query