diff options
author | Kamil TrzciĆski <kamil@gitlab.com> | 2017-08-21 18:46:45 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-09-08 03:22:16 +0300 |
commit | 4efd18d7e140bf2b6b95637af630e7294fcf28cc (patch) | |
tree | 107d92596480763bb1bd43ee85c6493ca18842a9 /app/serializers | |
parent | 4acab552be05e2ee1ccb6ba1997b770dd89c42bd (diff) |
Merge branch '29943-environment-folder' into 'security-9-5'
Do not use `location.pathname` when accessing environments folders
See merge request !2147
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/environment_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/environment_serializer.rb | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index dcaccc3007d..ba0ae6ba8a0 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -26,5 +26,9 @@ class EnvironmentEntity < Grape::Entity terminal_project_environment_path(environment.project, environment) end + expose :folder_path do |environment| + folder_project_environments_path(environment.project, environment.folder_name) + end + expose :created_at, :updated_at end diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index d0a60f134da..88842a9aa75 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -36,9 +36,9 @@ class EnvironmentSerializer < BaseSerializer private def itemize(resource) - items = resource.order('folder_name ASC') + items = resource.order('folder ASC') .group('COALESCE(environment_type, name)') - .select('COALESCE(environment_type, name) AS folder_name', + .select('COALESCE(environment_type, name) AS folder', 'COUNT(*) AS size', 'MAX(id) AS last_id') # It makes a difference when you call `paginate` method, because @@ -49,7 +49,7 @@ class EnvironmentSerializer < BaseSerializer environments = resource.where(id: items.map(&:last_id)).index_by(&:id) items.map do |item| - Item.new(item.folder_name, item.size, environments[item.last_id]) + Item.new(item.folder, item.size, environments[item.last_id]) end end end |