Using map to retrieve the element ids because of some issues with mysql

This commit is contained in:
Francisco Lopez 2017-12-01 11:34:24 +01:00
parent 3dc331c613
commit c5a89b35f0
3 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,6 @@
# Service class for getting and caching the number of elements 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.
module Projects
class BatchCountService
def initialize(projects)
@ -14,8 +17,6 @@ module Projects
end
def project_ids
return @projects if @projects.is_a?(ActiveRecord::Relation)
@projects.map(&:id)
end

View File

@ -1,5 +1,7 @@
# 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
module Projects
# Service class for getting and caching the number of forks of several projects
class BatchForksCountService < Projects::BatchCountService
def global_count
@global_count ||= begin

View File

@ -1,5 +1,7 @@
# Service class for getting and caching the number of issues 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
module Projects
# Service class for getting and caching the number of forks of several projects
class BatchOpenIssuesCountService < Projects::BatchCountService
def global_count
@global_count ||= begin