diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-06-06 23:19:39 +0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-06-08 17:26:05 +0300 |
commit | fade1a4cdebb4124048e9764486812627333ff95 (patch) | |
tree | b8911fb45861a1019f3724b74fffeca765fcc2d0 /lib/api/merge_requests.rb | |
parent | ad83c3085513dd248b979d445e545e88a17c6ebc (diff) |
Fix pseudo n+1 queries with Note and Note Authors in issuables APIs
This was not a clear cut n+1 query, given that if you're directly subscribed to all issues
that the API is returning you never really need to check for the notes. However, if you're
subscribed to _all_ of them, then for each issuable you need to go once to `notes`, and
once to `users` (for the authors). By preemtively loading notes and authors, at worst you have
1 extra query, and at best you saved 2n extra queries. We also took advantage of this preloading
of notes when counting user notes.
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r-- | lib/api/merge_requests.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 2e7836dc8fb..43221d5622a 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -41,7 +41,7 @@ module API # get ":id/merge_requests" do authorize! :read_merge_request, user_project - merge_requests = user_project.merge_requests + merge_requests = user_project.merge_requests.inc_notes_with_associations unless params[:iid].nil? merge_requests = filter_by_iid(merge_requests, params[:iid]) |