Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-02 20:31:36 +0300
committerStan Hu <stanhu@gmail.com>2019-03-06 18:03:46 +0300
commit062efe4f7a83fb2b6d951b314692cca9ee8731cd (patch)
tree2907359acdf497130b38c75555056226189af829 /lib/api/entities.rb
parenta592a78072bb44fed1a25c25f2cabdc4cf4bc0bd (diff)
Significantly reduce N+1 queries in /api/v4/todos endpoint
By preloading associations and batching issuable metadata lookups, we can significantly cut the number of SQL queries needed to load the Todos API endpoint. On GitLab.com, my own tests showed my user's SQL queries went from 365 to under 60 SQL queries. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/40378
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 5176e9713c1..2cd0d93b205 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -883,7 +883,8 @@ module API
expose :target_type
expose :target do |todo, options|
- todo_target_class(todo.target_type).represent(todo.target, options)
+ todo_options = options.fetch(todo.target_type, {})
+ todo_target_class(todo.target_type).represent(todo.target, todo_options)
end
expose :target_url do |todo, options|