summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-20 15:18:51 -0700
committerStan Hu <stanhu@gmail.com>2019-06-20 15:59:41 -0700
commit1b7ab11f9489690149f7ff1b78a927e5b3bbcfe0 (patch)
tree21d761c3baf2c37021c67b753e475be266b9aae8 /app/serializers
parent61a2ed5d0ec945e17f10b01c3eb1fc9e22c87bb1 (diff)
downloadgitlab-ce-1b7ab11f9489690149f7ff1b78a927e5b3bbcfe0.tar.gz
Omit issues links in merge request entity API response
The merge request widget has a section that includes which issues may be closed or mentioned based on the merge request description. The problem is that rendering and redacting Markdown can be expensive, especially since the browser polls for the data every 10 seconds. Since these links don't change much and are just nice to have, we only load them on first page load. The frontend will use the existing data if the data doesn't appear on subsequent requests. This saves about 30% of the rendering time of this endpoint, which adds up to significant savings considering that `MergeRequestsController#show.json` is called over a million times a day on GitLab.com. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63546
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/merge_request_widget_entity.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index a428930dbbf..43aced598a9 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -114,7 +114,10 @@ class MergeRequestWidgetEntity < IssuableEntity
presenter(merge_request).ci_status
end
- expose :issues_links do
+ # Rendering and redacting Markdown can be expensive. These links are
+ # just nice to have in the merge request widget, so only
+ # include them if they are explicitly requested on first load.
+ expose :issues_links, if: -> (_, opts) { opts[:issues_links] } do
expose :assign_to_closing do |merge_request|
presenter(merge_request).assign_to_closing_issues_link
end