diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_setting.rb | 6 | ||||
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/ci/job_artifact.rb | 13 | ||||
-rw-r--r-- | app/models/clusters/applications/runner.rb | 2 | ||||
-rw-r--r-- | app/models/namespace.rb | 1 | ||||
-rw-r--r-- | app/models/project.rb | 1 | ||||
-rw-r--r-- | app/models/project_services/pipelines_email_service.rb | 18 | ||||
-rw-r--r-- | app/models/project_statistics.rb | 16 | ||||
-rw-r--r-- | app/models/repository.rb | 2 |
9 files changed, 53 insertions, 10 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index fb1e558e46c..bbe2d2e8fd4 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -257,6 +257,12 @@ class ApplicationSetting < ApplicationRecord algorithm: 'aes-256-gcm', encode: true + attr_encrypted :lets_encrypt_private_key, + mode: :per_attribute_iv, + key: Settings.attr_encrypted_db_key_base_truncated, + algorithm: 'aes-256-gcm', + encode: true + before_validation :ensure_uuid! before_validation :strip_sentry_values diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 1b67a7272bc..56786fae6ea 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -765,6 +765,10 @@ module Ci end end + def report_artifacts + job_artifacts.with_reports + end + # Virtual deployment status depending on the environment status. def deployment_status return unless starts_environment? diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 3beb76ffc2b..0dbeab30498 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -26,10 +26,13 @@ module Ci metrics: 'metrics.txt' }.freeze - TYPE_AND_FORMAT_PAIRS = { + INTERNAL_TYPES = { archive: :zip, metadata: :gzip, - trace: :raw, + trace: :raw + }.freeze + + REPORT_TYPES = { junit: :gzip, metrics: :gzip, @@ -45,6 +48,8 @@ module Ci performance: :raw }.freeze + TYPE_AND_FORMAT_PAIRS = INTERNAL_TYPES.merge(REPORT_TYPES).freeze + belongs_to :project belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id @@ -66,6 +71,10 @@ module Ci where(file_type: types) end + scope :with_reports, -> do + with_file_types(REPORT_TYPES.keys.map(&:to_s)) + end + scope :test_reports, -> do with_file_types(TEST_REPORT_FILE_TYPES) end diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb index 01711e477b1..0dff91c3fe2 100644 --- a/app/models/clusters/applications/runner.rb +++ b/app/models/clusters/applications/runner.rb @@ -3,7 +3,7 @@ module Clusters module Applications class Runner < ApplicationRecord - VERSION = '0.5.0'.freeze + VERSION = '0.5.1'.freeze self.table_name = 'clusters_applications_runners' diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 7393ef4b05c..f7c31890198 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -76,6 +76,7 @@ class Namespace < ApplicationRecord 'namespaces.*', 'COALESCE(SUM(ps.storage_size), 0) AS storage_size', 'COALESCE(SUM(ps.repository_size), 0) AS repository_size', + 'COALESCE(SUM(ps.wiki_size), 0) AS wiki_size', 'COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size', 'COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size', 'COALESCE(SUM(ps.packages_size), 0) AS packages_size' diff --git a/app/models/project.rb b/app/models/project.rb index ab4da61dcf8..20895923d3b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -309,6 +309,7 @@ class Project < ApplicationRecord delegate :group_clusters_enabled?, to: :group, allow_nil: true delegate :root_ancestor, to: :namespace, allow_nil: true delegate :last_pipeline, to: :commit, allow_nil: true + delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true # Validations validates :creator, presence: true, on: :create diff --git a/app/models/project_services/pipelines_email_service.rb b/app/models/project_services/pipelines_email_service.rb index 7ba69370f14..ae5d5038099 100644 --- a/app/models/project_services/pipelines_email_service.rb +++ b/app/models/project_services/pipelines_email_service.rb @@ -2,11 +2,11 @@ class PipelinesEmailService < Service prop_accessor :recipients - boolean_accessor :notify_only_broken_pipelines + boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch validates :recipients, presence: true, if: :valid_recipients? def initialize_properties - self.properties ||= { notify_only_broken_pipelines: true } + self.properties ||= { notify_only_broken_pipelines: true, notify_only_default_branch: false } end def title @@ -54,7 +54,9 @@ class PipelinesEmailService < Service placeholder: _('Emails separated by comma'), required: true }, { type: 'checkbox', - name: 'notify_only_broken_pipelines' } + name: 'notify_only_broken_pipelines' }, + { type: 'checkbox', + name: 'notify_only_default_branch' } ] end @@ -67,6 +69,16 @@ class PipelinesEmailService < Service end def should_pipeline_be_notified?(data) + notify_for_pipeline_branch?(data) && notify_for_pipeline?(data) + end + + def notify_for_pipeline_branch?(data) + return true unless notify_only_default_branch? + + data[:object_attributes][:ref] == data[:project][:default_branch] + end + + def notify_for_pipeline?(data) case data[:object_attributes][:status] when 'success' !notify_only_broken_pipelines? diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index 6fe8cb40d25..832c8417b5b 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -4,9 +4,16 @@ class ProjectStatistics < ApplicationRecord belongs_to :project belongs_to :namespace + default_value_for :wiki_size, 0 + + # older migrations fail due to non-existent attribute without this + def wiki_size + has_attribute?(:wiki_size) ? super : 0 + end + before_save :update_storage_size - COLUMNS_TO_REFRESH = [:repository_size, :lfs_objects_size, :commit_count].freeze + COLUMNS_TO_REFRESH = [:repository_size, :wiki_size, :lfs_objects_size, :commit_count].freeze INCREMENTABLE_COLUMNS = { build_artifacts_size: %i[storage_size], packages_size: %i[storage_size] }.freeze def total_repository_size @@ -27,11 +34,14 @@ class ProjectStatistics < ApplicationRecord self.commit_count = project.repository.commit_count end - # Repository#size needs to be converted from MB to Byte. def update_repository_size self.repository_size = project.repository.size * 1.megabyte end + def update_wiki_size + self.wiki_size = project.wiki.repository.size * 1.megabyte + end + def update_lfs_objects_size self.lfs_objects_size = project.lfs_objects.sum(:size) end @@ -42,7 +52,7 @@ class ProjectStatistics < ApplicationRecord end def update_storage_size - self.storage_size = repository_size + lfs_objects_size + build_artifacts_size + packages_size + self.storage_size = repository_size + wiki_size + lfs_objects_size + build_artifacts_size + packages_size end # Since this incremental update method does not call update_storage_size above, diff --git a/app/models/repository.rb b/app/models/repository.rb index e05d3dd58ac..d43f991bb3e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1077,7 +1077,7 @@ class Repository end def rebase(user, merge_request) - if Feature.disabled?(:two_step_rebase, default_enabled: true) + if Feature.disabled?(:two_step_rebase, default_enabled: false) return rebase_deprecated(user, merge_request) end |