Modernise statistics script to work with rails 4.1