Refactor stats snapshot active record queries

My previous pull request made `Stats::Snapshot` worse by sprinkling
calls to `#to_i` in with a lot of the methods. I can't actually figure
out if/where this class is still used in the application, but in case it
is, this pull request tries to undo that damage and make
`Stats::Snapshot` better off than it was before I touched it.

1. Use more active record hash conditions and less sql string snippets

2. Using symbols instead of strings for created_at queries. This produces:
  `SELECT * FROM comments ORDER BY comments.created_at DESC`
  as opposed to:
  `SELECT * FROM comments ORDER BY created_at DESC`
which helps when joining to other tables that also have a created_at column

3. Simplify iso8601 time formatting method

4. Push some scopes further down, into the `Submission` and
`UserExercise` classes, from where their logic can be more easily
shared.