2018-07-17 12:50:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-01 05:34:24 -05:00
|
|
|
# Service class for getting and caching the number of forks of several projects
|
|
|
|
# Warning: do not user this service with a really large set of projects
|
|
|
|
# because the service use maps to retrieve the project ids
|
2017-11-24 07:20:52 -05:00
|
|
|
module Projects
|
|
|
|
class BatchForksCountService < Projects::BatchCountService
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-11-24 07:20:52 -05:00
|
|
|
def global_count
|
2017-11-30 06:52:38 -05:00
|
|
|
@global_count ||= begin
|
|
|
|
count_service.query(project_ids)
|
|
|
|
.group(:forked_from_project_id)
|
|
|
|
.count
|
|
|
|
end
|
2017-11-24 07:20:52 -05:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-11-24 07:20:52 -05:00
|
|
|
|
|
|
|
def count_service
|
|
|
|
::Projects::ForksCountService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|