diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-05 15:09:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-05 15:09:59 +0300 |
commit | b90cf01a88df981f452a7f6b6d74e8fd0ccbf90b (patch) | |
tree | 669bd8c7dab7f6aad2b9eef6d03cdb7bb4e687db /app/models/analytics | |
parent | f9053931de583bbc3c6a8033f70929a91ce02e93 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/analytics')
-rw-r--r-- | app/models/analytics/cycle_analytics/aggregation.rb | 8 | ||||
-rw-r--r-- | app/models/analytics/cycle_analytics/project_stage.rb | 3 |
2 files changed, 6 insertions, 5 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? diff --git a/app/models/analytics/cycle_analytics/project_stage.rb b/app/models/analytics/cycle_analytics/project_stage.rb index 8d3a032812e..68fe43890bd 100644 --- a/app/models/analytics/cycle_analytics/project_stage.rb +++ b/app/models/analytics/cycle_analytics/project_stage.rb @@ -5,8 +5,7 @@ module Analytics class ProjectStage < ApplicationRecord include Analytics::CycleAnalytics::Stage - validates :project, presence: true - belongs_to :project + belongs_to :project, optional: false belongs_to :value_stream, class_name: 'Analytics::CycleAnalytics::ProjectValueStream', foreign_key: :project_value_stream_id alias_attribute :parent, :project |