Extract last_known_revision logic to Deployment class

This should fix the Rubocop errors as well.
Although I do have the order mixed up. It should be `order("updated_at DESC").first` or `.order("updated_at ASC").last`.