Extract last_known_revision logic to Deployment class

This should fix the Rubocop errors as well.
I think you can just do `.limit(1)` here.