diff options
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/analytics_build_entity.rb | 7 | ||||
-rw-r--r-- | app/serializers/analytics_issue_entity.rb | 7 | ||||
-rw-r--r-- | app/serializers/environment_serializer.rb | 12 | ||||
-rw-r--r-- | app/serializers/group_child_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/merge_request_poll_cached_widget_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/merge_request_poll_widget_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/merge_request_sidebar_basic_entity.rb | 4 |
7 files changed, 38 insertions, 3 deletions
diff --git a/app/serializers/analytics_build_entity.rb b/app/serializers/analytics_build_entity.rb index 99663c8d5eb..169df94ad7b 100644 --- a/app/serializers/analytics_build_entity.rb +++ b/app/serializers/analytics_build_entity.rb @@ -9,6 +9,13 @@ class AnalyticsBuildEntity < Grape::Entity expose :ref, as: :branch expose :short_sha expose :author, using: UserEntity + expose :project_path do |build| + build.project.path + end + + expose :namespace_full_path do |build| + build.project.namespace.full_path + end expose :started_at, as: :date do |build| interval_in_words(build[:started_at]) diff --git a/app/serializers/analytics_issue_entity.rb b/app/serializers/analytics_issue_entity.rb index 307ce14a921..a0d6d120a48 100644 --- a/app/serializers/analytics_issue_entity.rb +++ b/app/serializers/analytics_issue_entity.rb @@ -6,6 +6,13 @@ class AnalyticsIssueEntity < Grape::Entity expose :title expose :author, using: UserEntity + expose :project_path do |object| + object[:project_path] + end + + expose :namespace_full_path do |object| + object[:namespace_path] + end expose :iid do |object| object[:iid].to_s diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index 2fb1ad52135..11445f93609 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -52,7 +52,17 @@ class EnvironmentSerializer < BaseSerializer end def batch_load(resource) - resource = resource.preload(environment_associations) + if ::Feature.enabled?(:custom_preloader_for_deployments, default_enabled: :yaml) + resource = resource.preload(environment_associations.except(:last_deployment, :upcoming_deployment)) + + Preloaders::Environments::DeploymentPreloader.new(resource) + .execute_with_union(:last_deployment, deployment_associations) + + Preloaders::Environments::DeploymentPreloader.new(resource) + .execute_with_union(:upcoming_deployment, deployment_associations) + else + resource = resource.preload(environment_associations) + end resource.all.to_a.tap do |environments| environments.each do |environment| diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb index 0ca6e7b40d9..c469dbdd6b8 100644 --- a/app/serializers/group_child_entity.rb +++ b/app/serializers/group_child_entity.rb @@ -33,6 +33,8 @@ class GroupChildEntity < Grape::Entity end # Project only attributes + expose :last_activity_at, if: lambda { |instance| project? } + expose :star_count, :archived, if: lambda { |_instance, _options| project? } diff --git a/app/serializers/merge_request_poll_cached_widget_entity.rb b/app/serializers/merge_request_poll_cached_widget_entity.rb index 8b0f3c8eb74..5bf02c93c99 100644 --- a/app/serializers/merge_request_poll_cached_widget_entity.rb +++ b/app/serializers/merge_request_poll_cached_widget_entity.rb @@ -17,7 +17,6 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity expose :target_project_id expose :squash expose :rebase_in_progress?, as: :rebase_in_progress - expose :default_squash_commit_message expose :commits_count expose :merge_ongoing?, as: :merge_ongoing expose :work_in_progress?, as: :work_in_progress @@ -27,6 +26,10 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity expose :source_branch_exists?, as: :source_branch_exists expose :branch_missing?, as: :branch_missing + expose :default_squash_commit_message do |merge_request| + merge_request.default_squash_commit_message(user: request.current_user) + end + expose :commits_without_merge_commits, using: MergeRequestWidgetCommitEntity do |merge_request| merge_request.recent_commits.without_merge_commits end diff --git a/app/serializers/merge_request_poll_widget_entity.rb b/app/serializers/merge_request_poll_widget_entity.rb index 074bd2d18d7..f68477e82c9 100644 --- a/app/serializers/merge_request_poll_widget_entity.rb +++ b/app/serializers/merge_request_poll_widget_entity.rb @@ -19,7 +19,9 @@ class MergeRequestPollWidgetEntity < Grape::Entity # User entities expose :merge_user, using: UserEntity - expose :default_merge_commit_message + expose :default_merge_commit_message do |merge_request, options| + merge_request.default_merge_commit_message(include_description: false, user: current_user) + end expose :mergeable do |merge_request, options| next merge_request.mergeable? if Feature.disabled?(:check_mergeability_async_in_widget, merge_request.project, default_enabled: :yaml) diff --git a/app/serializers/merge_request_sidebar_basic_entity.rb b/app/serializers/merge_request_sidebar_basic_entity.rb index 3c911bbe4c8..a0832655563 100644 --- a/app/serializers/merge_request_sidebar_basic_entity.rb +++ b/app/serializers/merge_request_sidebar_basic_entity.rb @@ -5,5 +5,9 @@ class MergeRequestSidebarBasicEntity < IssuableSidebarBasicEntity expose :can_merge do |merge_request| merge_request.can_be_merged_by?(current_user) end + + expose :can_update_merge_request do |merge_request| + current_user.can?(:update_merge_request, merge_request) + end end end |