diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 06:08:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 06:08:02 +0300 |
commit | ed73d4f207ef6cb8646719baa1188d096c9f3139 (patch) | |
tree | dea7ab9906154c73204a0361163e30500f929d44 /app/finders/deployments_finder.rb | |
parent | 2349eabc1a473bfb70555f0ce6d3d808cecb181d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders/deployments_finder.rb')
-rw-r--r-- | app/finders/deployments_finder.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/app/finders/deployments_finder.rb b/app/finders/deployments_finder.rb index 085c6a04fa6..b718b55dd68 100644 --- a/app/finders/deployments_finder.rb +++ b/app/finders/deployments_finder.rb @@ -22,9 +22,28 @@ class DeploymentsFinder private + # rubocop: disable CodeReuse/ActiveRecord def init_collection - project.deployments + project + .deployments + .includes( + :user, + environment: [], + deployable: { + job_artifacts: [], + pipeline: { + project: { + route: [], + namespace: :route + } + }, + project: { + namespace: :route + } + } + ) end + # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord def sort(items) @@ -43,6 +62,9 @@ class DeploymentsFinder order_by = ALLOWED_SORT_VALUES.include?(params[:order_by]) ? params[:order_by] : DEFAULT_SORT_VALUE order_direction = ALLOWED_SORT_DIRECTIONS.include?(params[:sort]) ? params[:sort] : DEFAULT_SORT_DIRECTION - { order_by => order_direction } + { order_by => order_direction }.tap do |sort_values| + sort_values['id'] = 'desc' if sort_values['updated_at'] + sort_values['id'] = sort_values.delete('created_at') if sort_values['created_at'] # Sorting by `id` produces the same result as sorting by `created_at` + end end end |