diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/models/analytics/cycle_analytics/aggregation.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/models/analytics/cycle_analytics/aggregation.rb')
-rw-r--r-- | app/models/analytics/cycle_analytics/aggregation.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/analytics/cycle_analytics/aggregation.rb b/app/models/analytics/cycle_analytics/aggregation.rb index a888422a6b4..b432955ad88 100644 --- a/app/models/analytics/cycle_analytics/aggregation.rb +++ b/app/models/analytics/cycle_analytics/aggregation.rb @@ -2,8 +2,7 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord include FromUnion - - belongs_to :group, optional: false + include Analytics::CycleAnalytics::Parentable validates :incremental_runtimes_in_seconds, :incremental_processed_records, :full_runtimes_in_seconds, :full_processed_records, presence: true, length: { maximum: 10 }, allow_blank: true @@ -58,7 +57,10 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord estimation < 1 ? nil : estimation.from_now end - def self.safe_create_for_group(group) + def self.safe_create_for_namespace(group_or_project_namespace) + # Namespaces::ProjectNamespace has no root_ancestor + # Related: https://gitlab.com/gitlab-org/gitlab/-/issues/386124 + group = group_or_project_namespace.is_a?(Group) ? group_or_project_namespace : group_or_project_namespace.parent top_level_group = group.root_ancestor aggregation = find_by(group_id: top_level_group.id) return aggregation if aggregation.present? |