The pull request with all the code.

you can probably throw all of the above in a constant on the ratings model.