Commit 3011d182 authored by Kamil Trzciński's avatar Kamil Trzciński

Make `Ci::Group` to be efficient

parent 08f22901
...@@ -9,6 +9,7 @@ module Ci ...@@ -9,6 +9,7 @@ module Ci
# #
class Group class Group
include StaticModel include StaticModel
include Gitlab::Utils::StrongMemoize
attr_reader :stage, :name, :jobs attr_reader :stage, :name, :jobs
...@@ -21,7 +22,11 @@ module Ci ...@@ -21,7 +22,11 @@ module Ci
end end
def status def status
@status ||= commit_statuses.status strong_memoize(:status) do
Gitlab::Ci::Status::GroupedStatuses
.new(@jobs)
.one[:status]
end
end end
def detailed_status(current_user) def detailed_status(current_user)
......
...@@ -21,7 +21,7 @@ module HasStatus ...@@ -21,7 +21,7 @@ module HasStatus
def status def status
Gitlab::Ci::Status::GroupedStatuses Gitlab::Ci::Status::GroupedStatuses
.new(all) .new(all)
.one&.dig(:status) .one[:status]
end end
def started_at def started_at
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Ci module Ci
class ProcessPipelineService < BaseService class ProcessPipelineService < BaseService
include Gitlab::Utils::StrongMemoize
attr_reader :pipeline attr_reader :pipeline
def execute(pipeline, trigger_build_ids = nil) def execute(pipeline, trigger_build_ids = nil)
......
...@@ -12,8 +12,11 @@ module Gitlab ...@@ -12,8 +12,11 @@ module Gitlab
def one(**query) def one(**query)
validate_keys!(query.keys) validate_keys!(query.keys)
item_hash = find_one(data_hash, query) if item_hash = find_one(data_hash, query)
status_for_key(query, item_hash) if item_hash status_for_key(query, item_hash)
else
{}
end
end end
def group(*keys) def group(*keys)
......
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