Commit 742d23a5 authored by Dylan Griffith's avatar Dylan Griffith

Use project_authorizations instead of members to calculate manageable CI...

Use project_authorizations instead of members to calculate manageable CI projects to speed up query (#41981)
parent 0e78c2e9
...@@ -997,7 +997,7 @@ class User < ActiveRecord::Base ...@@ -997,7 +997,7 @@ class User < ActiveRecord::Base
def ci_authorized_runners def ci_authorized_runners
@ci_authorized_runners ||= begin @ci_authorized_runners ||= begin
runner_ids = Ci::RunnerProject 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) .select(:runner_id)
Ci::Runner.specific.where(id: runner_ids) Ci::Runner.specific.where(id: runner_ids)
end end
...@@ -1208,18 +1208,6 @@ class User < ActiveRecord::Base ...@@ -1208,18 +1208,6 @@ class User < ActiveRecord::Base
], remove_duplicates: false) ], remove_duplicates: false)
end 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 # Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration
def send_devise_notification(notification, *args) def send_devise_notification(notification, *args)
return true unless can?(:receive_notifications) return true unless can?(:receive_notifications)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment