Class: Projects::BatchCountService
- Inherits:
-
Object
- Object
- Projects::BatchCountService
show all
- Defined in:
- app/services/projects/batch_count_service.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BatchCountService.
8
9
10
|
# File 'app/services/projects/batch_count_service.rb', line 8
def initialize(projects)
@projects = projects
end
|
Instance Method Details
#count_service ⇒ Object
29
30
31
|
# File 'app/services/projects/batch_count_service.rb', line 29
def count_service
raise NotImplementedError, 'count_service must be implemented and return a Projects::CountService object'
end
|
#global_count(project) ⇒ Object
25
26
27
|
# File 'app/services/projects/batch_count_service.rb', line 25
def global_count(project)
raise NotImplementedError, 'global_count must be implemented and return an hash indexed by the project id'
end
|
#project_ids ⇒ Object
21
22
23
|
# File 'app/services/projects/batch_count_service.rb', line 21
def project_ids
@projects.map(&:id)
end
|
#refresh_cache ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'app/services/projects/batch_count_service.rb', line 12
def refresh_cache
@projects.each do |project|
service = count_service.new(project)
unless service.count_stored?
service.refresh_cache { global_count[project.id].to_i }
end
end
end
|