Optimize Deployment#last_for_environment
In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22980/diffs#note_120036293 we discovered that Deployment#last_for_environment
is performing 2 queries to load deployments, this could be optimized to just one single query.
Furthermore, it seems like on the operations dashboard we would show failed or pending deployments instead of only the successful ones. @joshlambert & @sengelhard suggested that this should only include the successful ones