diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-05 13:12:21 +1000 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-09 10:46:42 +1000 |
commit | 742d23a5d0f61c9939d42605762b6fc073ae4f22 (patch) | |
tree | dbc0498193b9cf63c5cf561d632e2e3b80fbafa5 | |
parent | 0e78c2e9c925d180a443d132658691adf18f26a1 (diff) | |
download | gitlab-ce-742d23a5d0f61c9939d42605762b6fc073ae4f22.tar.gz |
Use project_authorizations instead of members to calculate manageable CI projects to speed up query (#41981)
-rw-r--r-- | app/models/user.rb | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 01ca1446376..25441d2b68f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -997,7 +997,7 @@ class User < ActiveRecord::Base def ci_authorized_runners @ci_authorized_runners ||= begin runner_ids = Ci::RunnerProject - .where("ci_runner_projects.project_id IN (#{ci_projects_union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection + .where(project: authorized_projects(Gitlab::Access::MASTER)) .select(:runner_id) Ci::Runner.specific.where(id: runner_ids) end @@ -1208,18 +1208,6 @@ class User < ActiveRecord::Base ], remove_duplicates: false) end - def ci_projects_union - manageable_other_projects = projects.where(members: { - access_level: [Gitlab::Access::MASTER, Gitlab::Access::OWNER] - }) - - Gitlab::SQL::Union.new([ - manageable_group_projects.select(:id), - personal_projects.select(:id), - manageable_other_projects.select(:id) - ]) - end - # Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration def send_devise_notification(notification, *args) return true unless can?(:receive_notifications) |