提交 742d23a5 编写于 作者: D 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)
上级 0e78c2e9
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册