Commit 2a915497 authored by Andreas Brandl's avatar Andreas Brandl

Extract executing batch counting

parent 105ac2b6
......@@ -93,7 +93,12 @@ module API
)
options[:with] = Entities::BasicProjectDetails if params[:simple]
present options[:with].prepare_relation(projects, options), options
projects = options[:with].prepare_relation(projects, options)
# Refresh count caches
options[:with].execute_batch_counting(projects)
present projects, options
end
def translate_params_for_compatibility(params)
......
......@@ -5,10 +5,9 @@ module API
extend ActiveSupport::Concern
class_methods do
# Prepare the given projects relation, e.g. perform preloading.
def prepare_relation(projects_relation, options = {})
projects_relation = preload_relation(projects_relation, options)
execute_batch_counting(projects_relation)
projects_relation
preload_relation(projects_relation, options)
end
def preload_relation(projects_relation, options = {})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment