gitlab-org--gitlab-foss/app
Sean McGivern 28e6af88aa Fix N+1 for notification recipients on private projects
If we don't call #to_a, we're relying on the members already being loaded from
elsewhere. Otherwise we'll do a separate query for each user:

    [1] pry(main)> Project.first.team.members.include?(User.first)
      Project Load (0.7ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" ASC LIMIT 1
      ↳ (pry):3
      User Load (1.8ms)  SELECT  "users".* FROM "users"  ORDER BY "users"."id" ASC LIMIT 1
      ↳ (pry):3
      User Exists (0.6ms)  SELECT  1 AS one FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1 AND "users"."id" = $2 LIMIT 1  [["project_id", 1], ["id", 1]]
      ↳ (pry):3
    => true
    [2] pry(main)> Project.first.team.members.to_a.include?(User.first)
      Project Load (12.8ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" ASC LIMIT 1
      ↳ (pry):1
      User Load (9.6ms)  SELECT "users".* FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1  [["project_id", 1]]
      ↳ (pry):1
      User Load (0.6ms)  SELECT  "users".* FROM "users"  ORDER BY "users"."id" ASC LIMIT 1
      ↳ (pry):1
    => true
2018-10-04 14:28:15 +01:00
..
assets Renders empty states in the Vue app in Job page 2018-10-04 12:59:57 +00:00
controllers Merge branch '49329-mr-show-commit-details' into 'master' 2018-10-04 11:37:33 +00:00
finders Remove vestigial method from MergeRequestsFinder 2018-10-04 10:40:16 +01:00
graphql Merge branch 'frozen-string-app-finders-graphql' into 'master' 2018-09-13 19:44:31 +00:00
helpers Merge branch '#51457-Show-percentage-of-language-detection-on-the-language-bar' into 'master' 2018-10-04 10:26:44 +00:00
mailers Ports new refactor from EE to CE 2018-09-24 12:02:26 +01:00
models Fix N+1 for notification recipients in subscribers 2018-10-04 14:27:36 +01:00
policies Fix N+1 for notification recipients on private projects 2018-10-04 14:28:15 +01:00
presenters Disable existing offenses for the CodeReuse cops 2018-09-11 17:32:00 +02:00
serializers Renders empty states in the Vue app in Job page 2018-10-04 12:59:57 +00:00
services Merge branch 'ce-7723-epic-commands-autocomplete' into 'master' 2018-10-04 11:25:55 +00:00
uploaders Backport of "Use Geo log to remove files when migrated to object storage" 2018-10-03 15:09:16 +00:00
validators Allow UrlValidator to work with attr_encrypted 2018-09-17 19:34:40 +01:00
views Renders empty states in the Vue app in Job page 2018-10-04 12:59:57 +00:00
workers Extend reports to support security features 2018-09-27 21:15:08 +00:00