2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-14 13:22:09 +00:00
|
|
|
module Projects
|
|
|
|
# Service class for getting and caching the number of forks of a project.
|
2017-11-15 14:47:10 +00:00
|
|
|
class ForksCountService < Projects::CountService
|
2020-07-09 15:08:59 +00:00
|
|
|
attr_reader :project
|
|
|
|
|
2017-08-17 15:21:25 +00:00
|
|
|
def cache_key_name
|
|
|
|
'forks_count'
|
2017-08-14 13:22:09 +00:00
|
|
|
end
|
2017-11-30 11:52:38 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-11-30 11:52:38 +00:00
|
|
|
def self.query(project_ids)
|
2018-08-31 17:16:34 +00:00
|
|
|
ForkNetworkMember.where(forked_from_project: project_ids)
|
2017-11-30 11:52:38 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-08-14 13:22:09 +00:00
|
|
|
end
|
|
|
|
end
|