diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 03:07:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 03:07:50 +0000 |
commit | 38bab6e1581d30c0e9d312474fd796404cc7b484 (patch) | |
tree | e4e6b11e2788cae577ecb1efa5195f9bc77b83f2 /lib/api/projects_relation_builder.rb | |
parent | 47b8f79a0896f406008d5a7eda2781f8da301e91 (diff) | |
download | gitlab-ce-38bab6e1581d30c0e9d312474fd796404cc7b484.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/projects_relation_builder.rb')
-rw-r--r-- | lib/api/projects_relation_builder.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/api/projects_relation_builder.rb b/lib/api/projects_relation_builder.rb new file mode 100644 index 00000000000..263468c9aa6 --- /dev/null +++ b/lib/api/projects_relation_builder.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module API + module ProjectsRelationBuilder + extend ActiveSupport::Concern + + class_methods do + def prepare_relation(projects_relation, options = {}) + projects_relation = preload_relation(projects_relation, options) + execute_batch_counting(projects_relation) + projects_relation + end + + def preload_relation(projects_relation, options = {}) + projects_relation + end + + def forks_counting_projects(projects_relation) + projects_relation + end + + def batch_forks_counting(projects_relation) + ::Projects::BatchForksCountService.new(forks_counting_projects(projects_relation)).refresh_cache + end + + def batch_open_issues_counting(projects_relation) + ::Projects::BatchOpenIssuesCountService.new(projects_relation).refresh_cache + end + + def execute_batch_counting(projects_relation) + batch_forks_counting(projects_relation) + batch_open_issues_counting(projects_relation) + end + end + end +end |