35 lines
997 B
Ruby
35 lines
997 B
Ruby
|
module API
|
||
|
module ProjectsRelationBuilder
|
||
|
extend ActiveSupport::Concern
|
||
|
|
||
|
module ClassMethods
|
||
|
def prepare_relation(relation)
|
||
|
relation = preload_relation(relation)
|
||
|
execute_batch_counting(relation)
|
||
|
relation
|
||
|
end
|
||
|
|
||
|
def preload_relation(relation)
|
||
|
raise NotImplementedError, 'self.preload_relation method must be defined and return a 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
|