Commit 45aef69c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extract builds queue processing into a separate method

This commit extracts builds queue processing into a separate method.
This method will be used to actually execute a builds queuing query on
the database. Separate method makes it easier to instrument execution of
this expensive query.
parent 60b9611e
......@@ -110,7 +110,7 @@ module Ci
end
if Feature.enabled?(:ci_register_job_service_one_by_one, runner, default_enabled: true)
build_ids = builds.pluck(:id)
build_ids = process_queue(-> { builds.pluck(:id) })
@metrics.observe_queue_size(-> { build_ids.size })
......@@ -118,13 +118,19 @@ module Ci
yield Ci::Build.find(build_id)
end
else
@metrics.observe_queue_size(-> { builds.to_a.size })
builds = process_queue(-> { builds.to_a })
@metrics.observe_queue_size(-> { builds.size })
builds.each(&blk)
end
end
# rubocop: enable CodeReuse/ActiveRecord
def process_queue(queue_query_proc)
queue_query_proc.call
end
def process_build(build, params)
unless build.pending?
@metrics.increment_queue_operation(:build_not_pending)
......
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