diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-23 18:15:13 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-26 11:23:11 +0100 |
commit | 6db014987d3c9cd4595adad70bb8a11ccacf9545 (patch) | |
tree | 581e3a1d9b93e0c5f9b9f442aaea3dc0fbeb72e0 /app/models/user.rb | |
parent | f66ec1bc8157e5481ba23660b226267293c85129 (diff) | |
download | gitlab-ce-6db014987d3c9cd4595adad70bb8a11ccacf9545.tar.gz |
Fix specific runner visibility
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 7e4321d5376..c72beacbf0f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -401,15 +401,17 @@ class User < ActiveRecord::Base end end + def authorized_projects_id + @authorized_projects_id ||= begin + project_ids = personal_projects.pluck(:id) + project_ids.push(*groups_projects.pluck(:id)) + project_ids.push(*projects.pluck(:id).uniq) + end + end # Projects user has access to def authorized_projects - @authorized_projects ||= begin - project_ids = personal_projects.pluck(:id) - project_ids.push(*groups_projects.pluck(:id)) - project_ids.push(*projects.pluck(:id).uniq) - Project.where(id: project_ids) - end + @authorized_projects ||= Project.where(id: authorized_projects_id) end def owned_projects @@ -768,11 +770,14 @@ class User < ActiveRecord::Base end def ci_authorized_projects - @ci_authorized_projects ||= Ci::Project.where(gitlab_id: authorized_projects) + @ci_authorized_projects ||= Ci::Project.where(gitlab_id: authorized_projects_id) end def ci_authorized_runners - Ci::Runner.specific.includes(:runner_projects). - where(ci_runner_projects: { project_id: ci_authorized_projects } ) + @ci_authorized_runners ||= begin + runner_ids = Ci::RunnerProject.joins(:project). + where(ci_projects: { gitlab_id: authorized_projects_id }).select(:runner_id) + Ci::Runner.specific.where(id: runner_ids) + end end end |