debian-mirror-gitlab/lib/api/projects_relation_builder.rb

36 lines
1,015 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module API
module ProjectsRelationBuilder
extend ActiveSupport::Concern
2018-11-20 20:47:30 +05:30
class_methods do
2018-03-17 18:26:18 +05:30
def prepare_relation(projects_relation, options = {})
projects_relation = preload_relation(projects_relation, options)
execute_batch_counting(projects_relation)
2020-07-28 23:09:34 +05:30
# Call the forks count method on every project, so the BatchLoader would load them all at
# once when the entities are rendered
projects_relation.each(&:forks_count)
2018-03-17 18:26:18 +05:30
projects_relation
end
2019-03-02 22:35:43 +05:30
def preload_relation(projects_relation, options = {})
2018-03-17 18:26:18 +05:30
projects_relation
end
def forks_counting_projects(projects_relation)
projects_relation
end
def batch_open_issues_counting(projects_relation)
::Projects::BatchOpenIssuesCountService.new(projects_relation).refresh_cache
end
def execute_batch_counting(projects_relation)
batch_open_issues_counting(projects_relation)
end
end
end
end