diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_setting.rb | 4 | ||||
-rw-r--r-- | app/models/diff_viewer/server_side.rb | 8 | ||||
-rw-r--r-- | app/models/experiment.rb | 32 | ||||
-rw-r--r-- | app/models/experiment_user.rb | 14 | ||||
-rw-r--r-- | app/models/integrations/datadog.rb | 2 | ||||
-rw-r--r-- | app/models/ml/candidate.rb | 4 |
6 files changed, 9 insertions, 55 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 361b1a8dca9..a1bef44a815 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -636,6 +636,10 @@ class ApplicationSetting < ApplicationRecord addressable_url: { allow_localhost: true, allow_local_network: false }, allow_blank: true + validates :product_analytics_enabled, + presence: true, + allow_blank: true + attr_encrypted :asset_proxy_secret_key, mode: :per_attribute_iv, key: Settings.attr_encrypted_db_key_base_truncated, diff --git a/app/models/diff_viewer/server_side.rb b/app/models/diff_viewer/server_side.rb index a1defb2594f..fb127de2bc7 100644 --- a/app/models/diff_viewer/server_side.rb +++ b/app/models/diff_viewer/server_side.rb @@ -9,14 +9,6 @@ module DiffViewer self.size_limit = 5.megabytes end - def prepare! - return if Feature.enabled?(:disable_load_entire_blob_for_diff_viewer, diff_file.repository.project) - - # TODO: remove this after resolving #342703 - diff_file.old_blob&.load_all_data! - diff_file.new_blob&.load_all_data! - end - def render_error # Files that are not stored in the repository, like LFS files and # build artifacts, can only be rendered using a client-side viewer, diff --git a/app/models/experiment.rb b/app/models/experiment.rb index 2300ec2996d..3710abc46ea 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -1,50 +1,18 @@ # frozen_string_literal: true class Experiment < ApplicationRecord - has_many :experiment_users has_many :experiment_subjects, inverse_of: :experiment validates :name, presence: true, uniqueness: true, length: { maximum: 255 } - def self.add_user(name, group_type, user, context = {}) - by_name(name).record_user_and_group(user, group_type, context) - end - - def self.add_group(name, variant:, group:) - add_subject(name, variant: variant, subject: group) - end - def self.add_subject(name, variant:, subject:) by_name(name).record_subject_and_variant!(subject, variant) end - def self.record_conversion_event(name, user, context = {}) - by_name(name).record_conversion_event_for_user(user, context) - end - def self.by_name(name) find_or_create_by!(name: name) end - # Create or update the recorded experiment_user row for the user in this experiment. - def record_user_and_group(user, group_type, context = {}) - experiment_user = experiment_users.find_or_initialize_by(user: user) - experiment_user.assign_attributes(group_type: group_type, context: merged_context(experiment_user, context)) - # We only call save when necessary because this causes the request to stick to the primary DB - # even when the save is a no-op - # https://gitlab.com/gitlab-org/gitlab/-/issues/324649 - experiment_user.save! if experiment_user.changed? - - experiment_user - end - - def record_conversion_event_for_user(user, context = {}) - experiment_user = experiment_users.find_by(user: user) - return unless experiment_user - - experiment_user.update!(converted_at: Time.current, context: merged_context(experiment_user, context)) - end - def record_conversion_event_for_subject(subject, context = {}) raise 'Incompatible subject provided!' unless ExperimentSubject.valid_subject?(subject) diff --git a/app/models/experiment_user.rb b/app/models/experiment_user.rb deleted file mode 100644 index e447becc1bd..00000000000 --- a/app/models/experiment_user.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class ExperimentUser < ApplicationRecord - include ::Gitlab::Experimentation::GroupTypes - - belongs_to :experiment - belongs_to :user - - enum group_type: { GROUP_CONTROL => 0, GROUP_EXPERIMENTAL => 1 } - - validates :experiment_id, presence: true - validates :user_id, presence: true - validates :group_type, presence: true -end diff --git a/app/models/integrations/datadog.rb b/app/models/integrations/datadog.rb index ab0fdbd777f..d4867600853 100644 --- a/app/models/integrations/datadog.rb +++ b/app/models/integrations/datadog.rb @@ -91,7 +91,7 @@ module Integrations with_options if: :activated? do validates :api_key, presence: true, format: { with: /\A\w+\z/ } - validates :datadog_site, format: { with: /\A[\w\.]+\z/, allow_blank: true } + validates :datadog_site, format: { with: %r{\A\w+([-.]\w+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?\z}, allow_blank: true } validates :api_url, public_url: { allow_blank: true } validates :datadog_site, presence: true, unless: -> (obj) { obj.api_url.present? } validates :api_url, presence: true, unless: -> (obj) { obj.datadog_site.present? } diff --git a/app/models/ml/candidate.rb b/app/models/ml/candidate.rb index 29e1ba88528..62e2e75db2a 100644 --- a/app/models/ml/candidate.rb +++ b/app/models/ml/candidate.rb @@ -14,6 +14,10 @@ module Ml default_value_for(:iid) { SecureRandom.uuid } + def artifact_root + "/ml_candidate_#{iid}/-/" + end + class << self def with_project_id_and_iid(project_id, iid) return unless project_id.present? && iid.present? |